我需要问我应该如何在警报对话框中充气三个按钮。基本上可以使用列表视图,当用户长按列表项时,应该出现一个警告对话框,对话框应该有编辑,删除和其他按钮,按钮应该在按下时执行它们的任务,我真的很感激它如果有人能告诉我,我应该怎么吹的警告对话框中与buttons.Thanks在警告对话框中充气视图
0
A
回答
1
不需要发明轮子两次.. 其所谓的上下文菜单: http://developer.android.com/guide/topics/ui/menus.html
1
如果使用AlertDialog .Buider你可以添加三个按钮。
new AlertDialog.Builder(this)
.setPositiveButton("Edit", new OnClickListener()
{
// Code Here
})
.setNeutralButton("Delete", new OnClickListener()
{
// Code Here
})
.setNegativeButton("Delete", new OnClickListener()
{
// Code Here
})
.create()
.show();
0
您可以使用上下文菜单,就像这样:
final OnCreateContextMenuListener occml = new OnCreateContextMenuListener() {
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
menu.setHeaderTitle(pi.getBrowserIdentifier());
menu.add(R.id.actionBarMenu_Settings, R.string.one, 1, getString(R.string.one));
menu.add(R.id.actionBarMenu_Settings, R.string.two, 2, getString(R.two));
menu.add(R.id.actionBarMenu_Settings, R.string.three, 3, getString(R.string.three));
};
_listView= (ListView) findViewById(R.id.list);
_listView.setOnCreateContextMenuListener(occml);
0
我这样做是这样,你也可以
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Seçenekler");
builder.setAdapter(/*#your adapter here#*/, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//do something
}
});
0
下一个代码捕获视图覆盖的setView在自定义对话框类扩展了alertdialog:
class example extends Activity{
private void onClick_show_dialog(View v)
{
LayoutInflater lainf = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View frmFileSystem = lainf.inflate(R.layout.dlg_filesystem, (ViewGroup) findViewById(R.id.lilaFileSystem));
dlg_filesystem = new DlgFileSystem(this);
dlg_filesystem.setView(frmFileSystem);
dlg_filesystem.setCancelable(true);
dlg_filesystem.setButton('aceptar' , new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which)
{
alert(dlg_filesystem.prueba);
}});
dlg_filesystem.setButton2('cancelar' , new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which)
{
}});
dlg_filesystem.show();
}
}
and
public class DlgFileSystem extends AlertDialog{
public String prueba;
private Context context;
private View frmFileSystem;
public DlgFileSystem(Context context)
{
super(context);
this.context = context;
}
@Override
public void setView(View frmFileSystem)
{
super.setView(frmFileSystem);
this.frmFileSystem = frmFileSystem;
TextView txprueba = (TextView)frmFileSystem.findViewById(R.id.txPrueba);
txprueba.setText("adios");
}
}
相关问题
- 1. 对话框充气
- 2. 显示对话框在视图中充气由windowmanager在android中
- 3. 填充警告对话框与列表视图,JSON
- 4. 在警告对话框
- 5. ClassNotFound异常,而在警报框中充气视图
- 6. 从自定义对话框视图充气时,EditText为null
- 7. 没有警告对话框的图标
- 8. jqGrid警告对话框
- 9. 警告对话框准备
- 10. Android的警告对话框
- 11. 多个警告对话框
- 12. libGDX警告对话框
- 13. 安卓:警告对话框
- 14. 调用show()后在对话框中调整充气膨胀视图
- 15. 定制警告对话框包含多个视图
- 16. 会话超时警告对话框MVC
- 17. 定制警告对话框中的Android
- 18. Android的警告对话框在2.1
- 19. 充气视图android
- 20. 在OnCreateView内充气视图
- 21. 移除填充围绕警告对话框
- 22. 在警报对话框中填充微调框
- 23. 带有警报对话框中复选框的列表视图
- 24. 看一个警告对话框
- 25. BB对话框显示之前警告
- 26. 警告对话框不工作
- 27. 警告对话框不会为列表
- 28. 访问按钮的警告对话框
- 29. 如何从警告对话框
- 30. 的Android警告对话框不工作