我面临一个问题。我有一个扩展 listactivity 的类,它的代码是这样的:
public class QuestionListActivity extends ListActivity
{
//Members
private ImageButton bntRefresh;
private ImageButton bntSettings;
private ImageButton bntGetSurveys;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.surveylist);
initialize();
currentSurveys=new SurveyList();
}
private void initialize()
{
bntRefresh= (ImageButton) findViewById(R.id.ibtnRefresh);
bntRefresh.setImageResource(R.drawable.refresh);
bntRefresh.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(SurveyListActivity.this, "This will refresh the survey list.", Toast.LENGTH_SHORT).show();
}
});
bntSettings= (ImageButton) findViewById(R.id.ibtnSettings);
bntSettings.setImageResource(R.drawable.settings);
bntSettings.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(SurveyListActivity.this, "This will open the settings.", Toast.LENGTH_SHORT).show();
}
});
bntGetSurveys= (ImageButton) findViewById(R.id.ibtnGetSurveys);
bntGetSurveys.setImageResource(R.drawable.getsurvey);
bntGetSurveys.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
AlertDialog getSurveyAlert = new AlertDialog.Builder(QuestionListActivity .this).create();
getSurveyAlert.setTitle("Enter QR Code");
getSurveyAlert.setMessage("Choose a source");
getSurveyAlert.setButton("Camera", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
getSurveyAlert.setButton2("text", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
}
});
}
class SurveyAdapter extends ArrayAdapter<Survey>
{
//-- code here for adapter
}
}
在我的初始化函数中,您可以看到我有三个图像按钮,并且我已经为它们实现了 onClicklisteners。对于设置和刷新按钮,我展示了一个 Toast,它工作正常。对于获取按钮,我显示了一个对话框,进一步要求用户执行某些操作,但我面临的问题是对话框没有出现,我不知道为什么?