public class LoadingDialog extends EnhancedDialog{
private ProgressBar Progress;
private Button SamplePlay;
private Button GamePlay;
private LoadingDialog dialog;
private Context context;
public LoadingDialog(Context context) {
super(context);
this.context = context;
// TODO Auto-generated constructor stub
dialog = this;
}
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(com.Planet.R.layout.loading_dialog, null);
Progress = (ProgressBar)v.findViewById(com.Planet.R.id.progressBar1);
SamplePlay = (Button)v.findViewById(com.Planet.R.id.SamplePlay);
GamePlay = (Button)v.findViewById(com.Planet.R.id.start);
SamplePlay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
samplePlay(State.getMusic());
}
});
GamePlay.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
});
setContentView(com.Planet.R.layout.loading_dialog);
}
private void samplePlay(Music m){
try{
Log.d("Start sampleMusic","test!!!");
MusicManager.mPlayer.reset();
MusicManager.mPlayer.setDataSource(m.getMusicPath());
MusicManager.mPlayer.prepare();
MusicManager.mPlayer.seekTo(0);
MusicManager.mPlayer.start();
}catch(Exception e){
Log.d("Loading Dialog", e.getMessage());
}
}
@Override
public void dismiss(){
super.dismiss();
MusicManager.mPlayer.reset();
}
}
이와 같이 구성을 하였는데 onClickListener가 제대로 등록이 안되네요.
에러메세지는 없는데, 버튼이 작동을 안합니다.
처음에는 아래 두라인이 없는 형식으로 작성을 했었는데
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(com.Planet.R.layout.loading_dialog, null);
Veiw.setOnClickListener에서 널포인터 익셉션이 발생했구요.
비슷한 문제 겪으신분 계신가요?