# Android - SoundEdit : android, SoundEdit
```java
package exam.Widget;
import android.app.*;
import android.content.*;
import android.media.*;
import android.os.*;
import android.util.*;
import android.view.*;
import android.widget.*;
import exam.AndroidExam.*;
public class SoundEdit extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.widget_soundedit);
}
}
class SoundEditWidget extends EditText {
SoundPool mPool = null;
int mClick;
public SoundEditWidget(Context context) {
super(context);
init(context);
}
public SoundEditWidget(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public SoundEditWidget(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context);
}
void init(Context context) {
mPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
mClick = mPool.load(context, R.raw.click, 1);
}
protected void onTextChanged(CharSequence text, int start, int before, int after) {
if (mPool != null) {
mPool.play(mClick, 1, 1, 0, 0, 1);
}
}
}
```
#### widget_soundedit.xml
```xml
```
```java
package exam.Widget;
import android.app.*;
import android.content.*;
import android.content.res.*;
import android.media.*;
import android.os.*;
import android.util.*;
import android.widget.*;
import exam.AndroidExam.*;
public class SoundEdit2 extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.widget_soundedit2);
}
}
class SoundEditWidget2 extends EditText {
SoundPool mPool = null;
int mClick1, mClick2;
int mSound;
float mVolume = 1.0f;
float mSpeed = 1.0f;
public SoundEditWidget2(Context context) {
super(context);
init(context, null);
}
public SoundEditWidget2(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
public SoundEditWidget2(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context, attrs);
}
void init(Context context, AttributeSet attrs) {
mPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
mClick1 = mPool.load(context, R.raw.click, 1);
mClick2 = mPool.load(context, R.raw.click2, 1);
mSound = mClick1;
if (attrs != null) {
TypedArray ar = context.obtainStyledAttributes(attrs, R.styleable.SoundEditWidget2);
mVolume = ar.getFloat(R.styleable.SoundEditWidget2_volume, 1.0f);
mSpeed = ar.getFloat(R.styleable.SoundEditWidget2_speed, 1.0f);
mSound = ar.getInt(R.styleable.SoundEditWidget2_sound, mClick1);
ar.recycle();
}
}
protected void onTextChanged(CharSequence text, int start, int before, int after) {
if (mPool != null) {
mPool.play(mSound, mVolume, mVolume, 0, 0, mSpeed);
}
}
}
```
#### widget_soundedit2.xml
```
댓글