久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 onClick 事件之后創建一個對話框

Creating a Dialog after an onClick event(在 onClick 事件之后創建一個對話框)
本文介紹了在 onClick 事件之后創建一個對話框的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

您好,我是第一次使用對話框.我想在單擊 listView 中的項目后創建一個對話框:

Hi i am working the first time with dialogs. i want to create a dialog after an item in a listView was clicked:

    String[] listItems = {"Colour", "Font Size",};
    ListView lv = (ListView) findViewById(R.id.settings_list);

    lv.setAdapter(new ArrayAdapter<String>
    (this, android.R.layout.simple_list_item_1, listItems));

    lv.setOnItemClickListener(new OnItemClickListener()
    {
        public void onItemClick(AdapterView<?> parent, View
                view, int position, long id)
        {
            String[] listItems = {"Colour", "Font Size",};
            if(listItems[position].equals("Font Size"))
            {


                    public dialog onCreateDialog(Bundle savedInstanceState)
                    {
                        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                        builder.setTitle("Choose Font Size");
                    }



            }

        }
    });

我在 onCreateDialog(Bundle savedInstanceState) 收到錯誤Eclipse 想要一個 ;圍繞Bundle savedInstanceState,但developer.android另有說明.有什么建議嗎?

I get an error at onCreateDialog(Bundle savedInstanceState) Eclipse wants a ; around Bundle savedInstanceState, but developer.android says otherwise. Any tips?

推薦答案

在你的 onItemClick 方法中調用這個方法:

Call this method in your onItemClick method :

 public void showMyCustomDialog(Context context, String title, String message)
    {
        final Dialog dialog = new Dialog(context);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        //tell the Dialog to use the customalertdialog.xml as it's layout description
        dialog.setContentView(R.layout.customalertdialog);
        TextView titleText = (TextView) dialog.findViewById(R.id.txtTitleAlertDialog);
        titleText.setText(title);
        TextView txt = (TextView) dialog.findViewById(R.id.txtAlertDialog);
        txt.setText(message);
        Button dialogButton = (Button) dialog.findViewById(R.id.buttonAlertDialogCancel);
        dialogButton.setText("OK");
        dialogButton.setOnClickListener(new View.OnClickListener() 
        {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
    }

如下所示:

lv.setOnItemClickListener(new OnItemClickListener()
    {
        public void onItemClick(AdapterView<?> parent, View
                view, int position, long id)
        {
            String[] listItems = {"Colour", "Font Size",};
            if(listItems[position].equals("Font Size"))
            {
                    public dialog onCreateDialog(Bundle savedInstanceState)
                    {
                        showMyCustomDialog(Context context, String title, String message) // pass title, message and activity context in this method.
                    }
            }
        }
    });

希望它會有所幫助.

這篇關于在 onClick 事件之后創建一個對話框的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to wrap text around components in a JTextPane?(如何在 JTextPane 中的組件周圍環繞文本?)
MyBatis, how to get the auto generated key of an insert? [MySql](MyBatis,如何獲取插入的自動生成密鑰?[MySql])
Inserting to Oracle Nested Table in Java(在 Java 中插入 Oracle 嵌套表)
Java: How to insert CLOB into oracle database(Java:如何將 CLOB 插入 oracle 數據庫)
Why does Spring-data-jdbc not save my Car object?(為什么 Spring-data-jdbc 不保存我的 Car 對象?)
Use threading to process file chunk by chunk(使用線程逐塊處理文件)
主站蜘蛛池模板: 国产精品成av人在线视午夜片 | 亚洲精品一区中文字幕乱码 | 久久国产综合 | 国产精品毛片一区二区三区 | 日韩和的一区二区 | 日本精品一区二区三区视频 | 一区二区三区四区在线 | 日本一二三区在线观看 | 一区视频 | 91免费版在线观看 | 国产成人高清 | 国产视频一区二区在线观看 | 日韩精品在线免费观看视频 | 黑人中文字幕一区二区三区 | 91精品国产91 | 中文字幕乱码一区二区三区 | 亚洲精品久久久久久下一站 | 欧美日一区二区 | 久久一区二区三区电影 | 精品久久久久久亚洲精品 | 国产精品久久久久久久久免费软件 | 亚洲视频二区 | 国产在线观看av | 91久久精品一区二区二区 | 欧美一区二区在线观看 | 久久久久久久亚洲精品 | 久草新视频 | 狠狠入ady亚洲精品经典电影 | 亚洲乱码国产乱码精品精98午夜 | 午夜精品久久久 | 国产精品日产欧美久久久久 | 神马久久久久久久久久 | 亚洲精品综合 | 草草视频在线免费观看 | 欧美性一区二区三区 | 天堂中文在线观看 | 亚洲精品久久久久久久不卡四虎 | 不卡一区二区在线观看 | 看一级黄色毛片 | 日韩国产在线观看 | 国产1区2区3区 |