English 中文(简体)
警报对话框内放大视图
原标题:Inflating view inside an alert dialog
  • 时间:2012-05-23 14:40:16
  •  标签:
  • android

我需要询问我应该如何在一个提醒对话框中充气 三个按钮 。 基本上, 列表视图是可用的 。 当用户在列表项上按下, 提醒对话框应该出现, 对话框应该编辑、 删除和一些其他按钮, 按钮按下时应该执行任务, 我非常感激, 如果有人能告诉我, 我应该如何用按钮放大提醒对话框 。 谢谢 。

最佳回答

No need to invent the wheel twice.. Its called a context menu: http://developer.android.com/guide/topics/ui/menus.html

问题回答

如果您使用AwardDialog. 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();

您可以使用上下文菜单,例如:

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);

我这样做,你也可以

    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
                        }
                    });

下一个代码捕捉到自定义对话框类中的视图覆盖覆盖提醒对话框 : @ info: whatsthis

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();
}

}

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");
}   
}




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签