久久久久久久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(使用線程逐塊處理文件)
主站蜘蛛池模板: 日本aaaa| 欧美国产在线一区 | 美女在线国产 | 亚洲国产成人av好男人在线观看 | 午夜免费电影院 | 精品国产乱码久久久久久蜜臀 | 午夜精品久久久久久久久久久久 | 天天操夜夜艹 | 亚洲免费视频一区 | 日韩欧美国产精品一区 | 久久久久久久一区二区 | 小h片免费观看久久久久 | 精品国产精品国产偷麻豆 | 国产成人免费在线 | 一区二区三区四区毛片 | 看片一区 | 69热视频在线观看 | 久久中文字幕一区 | 在线观看特色大片免费网站 | 国产黄色在线观看 | 91精品国产色综合久久不卡98口 | 伊人久久精品 | 亚洲精品乱码久久久久久按摩 | 欧美成人aaa级毛片在线视频 | 国产乱码精品1区2区3区 | 日本a视频 | 免费在线观看一区二区 | 毛片一级片 | 国产成人免费 | av在线天天 | 亚洲欧美日韩在线 | 国产精品亚洲精品日韩已方 | 一区二区免费 | 午夜免费看视频 | 91av亚洲| 一区二区三区av | 亚洲一区二区三区四区五区中文 | 久久国产成人午夜av影院武则天 | 国产中文字幕亚洲 | 成人国产午夜在线观看 | 午夜大片 |