如何在我的應用程序中添加第3個按鈕......我想將第三個按鈕設置爲「收聽」....我已經檢查如何在我的應用程序中添加第3個按鈕
.setNeutralButton
但它不工作....它怎麼可能?
public class MessageViewPage extends Activity {
ScrollView sv;
String nickname,body;
private LinearLayout mainLayout;
final Context context = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.message_view_page);
Bundle b = getIntent().getExtras();
nickname= b.getString("nick");
body=b.getString("body");
System.out.println(nickname);
System.out.println(body);
mainLayout=(LinearLayout)findViewById(R.id.mainLayoutmess);
mainLayout.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
System.out.println("***************in on click************");
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
// set title
alertDialogBuilder.setTitle("Access");
// set dialog message
alertDialogBuilder
.setMessage("What's next?")
.setCancelable(false)
.setPositiveButton("Reply",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
Intent i=new Intent(MessageViewPage.this,Reply.class);
startActivity(i);
finish();
}
})
.setNegativeButton("Cancel",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
dialog.cancel();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
});
}
}
與.setNeutralButton ........具有錯誤
而不.setNeutralButton ....沒有錯誤
你需要的是一個自定義對話框。 下面是如何把它做[http://stackoverflow.com/questions/5544405/android-custom-dialog][1] [1]:http://stackoverflow.com/questions/5544405/android-custom-dialog – the100rabh 2012-07-06 11:36:59
將此鏈接指向自定義對話框http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog,tis one for question http://www.androidhive.info/2011/09 /如何顯示警報對話框在android/ – KMI 2012-07-06 11:39:05
通過定義**自定義對話框**,你可以有多達你想要的按鈕。 – 2012-07-06 11:40:40