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

<i id='Aj5lG'><tr id='Aj5lG'><dt id='Aj5lG'><q id='Aj5lG'><span id='Aj5lG'><b id='Aj5lG'><form id='Aj5lG'><ins id='Aj5lG'></ins><ul id='Aj5lG'></ul><sub id='Aj5lG'></sub></form><legend id='Aj5lG'></legend><bdo id='Aj5lG'><pre id='Aj5lG'><center id='Aj5lG'></center></pre></bdo></b><th id='Aj5lG'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Aj5lG'><tfoot id='Aj5lG'></tfoot><dl id='Aj5lG'><fieldset id='Aj5lG'></fieldset></dl></div>

    • <bdo id='Aj5lG'></bdo><ul id='Aj5lG'></ul>

      <small id='Aj5lG'></small><noframes id='Aj5lG'>

      <legend id='Aj5lG'><style id='Aj5lG'><dir id='Aj5lG'><q id='Aj5lG'></q></dir></style></legend>

      <tfoot id='Aj5lG'></tfoot>

      Android - 在自定義對話框中正確執(zhí)行自定義列表視

      Android - Executing a custom listview in a custom dialog properly(Android - 在自定義對話框中正確執(zhí)行自定義列表視圖)

          <bdo id='5iufL'></bdo><ul id='5iufL'></ul>
          <legend id='5iufL'><style id='5iufL'><dir id='5iufL'><q id='5iufL'></q></dir></style></legend>

            1. <tfoot id='5iufL'></tfoot>
              <i id='5iufL'><tr id='5iufL'><dt id='5iufL'><q id='5iufL'><span id='5iufL'><b id='5iufL'><form id='5iufL'><ins id='5iufL'></ins><ul id='5iufL'></ul><sub id='5iufL'></sub></form><legend id='5iufL'></legend><bdo id='5iufL'><pre id='5iufL'><center id='5iufL'></center></pre></bdo></b><th id='5iufL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5iufL'><tfoot id='5iufL'></tfoot><dl id='5iufL'><fieldset id='5iufL'></fieldset></dl></div>
                <tbody id='5iufL'></tbody>

              <small id='5iufL'></small><noframes id='5iufL'>

                本文介紹了Android - 在自定義對話框中正確執(zhí)行自定義列表視圖的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                問題描述

                我有一個應(yīng)用程序,我想在 android 的自定義對話框中顯示一個由兩個 textView 組成的自定義列表視圖.到目前為止,我很難弄清楚如何將兩者聯(lián)系起來并生成對話框的內(nèi)容.

                I have an application where I would want to display a custom list view consisting of two textViews inside a custom dialog box in android. So far, I'm having a difficult time figuring out how to connect the two and generate the contents of the dialog box.

                我嘗試按照自定義 listView 教程進(jìn)行操作,希望只是將對話框適配器設(shè)置為它,但無濟于事.

                I tried to follow custom listView tutorials with the hopes of just setting the dialog adapter to it but to no avail.

                到目前為止,這是我目前所擁有的:

                So far, this is what I have so far:

                這是 list_row_dialog.xml,包含兩個文本視圖的行的布局:

                This is list_row_dialog.xml, the layout for the row containing two textviews:

                <?xml version="1.0" encoding="utf-8"?>
                <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:minHeight="50dp"
                    android:orientation="horizontal"
                    android:padding="5dip" >
                
                <TextView
                    android:id="@+id/unit"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textStyle="bold"
                    android:typeface="sans" />
                
                <TextView
                    android:id="@+id/quantity"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_alignParentTop="true"
                    android:textColor="#343434"
                    android:textSize="12sp" />
                
                </RelativeLayout>
                

                這里是 dialog_main.xml 文件,我希望對話框使用的布局文件,它基本上是一個 listView.

                And here is the dialog_main.xml file, the layout file that I want the dialog box to use, it's basically a listView.

                <?xml version="1.0" encoding="utf-8"?>
                <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:orientation="vertical" >
                
                <ListView
                    android:id="@+id/custom_list"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:dividerHeight="1dp" />
                
                </LinearLayout>
                

                這里是CustomListAdapterDialog.java,我什至不確定是否需要使用它在對話框上顯示數(shù)據(jù):

                And here's CustomListAdapterDialog.java, I'm not sure if I even need to use this to display data on the dialog box:

                public class CustomListAdapterDialog extends BaseAdapter {
                
                private ArrayList<ItemClass> listData;
                
                private LayoutInflater layoutInflater;
                
                public CustomListAdapterDialog(Context context, ArrayList<ItemClass> listData) {
                    this.listData = listData;
                    layoutInflater = LayoutInflater.from(context);
                }
                
                @Override
                public int getCount() {
                    return listData.size();
                }
                
                @Override
                public Object getItem(int position) {
                    return listData.get(position);
                }
                
                @Override
                public long getItemId(int position) {
                    return position;
                }
                
                public View getView(int position, View convertView, ViewGroup parent) {
                    ViewHolder holder;
                    if (convertView == null) {
                        convertView = layoutInflater.inflate(R.layout.list_row_dialog, null);
                        holder = new ViewHolder();
                        holder.unitView = (TextView) convertView.findViewById(R.id.unit);
                        holder.quantityView = (TextView) convertView.findViewById(R.id.quantity);
                        convertView.setTag(holder);
                    } else {
                        holder = (ViewHolder) convertView.getTag();
                    }
                
                    holder.unitView.setText(listData.get(position).getVariant().toString());
                    holder.quantityView.setText(listData.get(position).getUnit().toString());
                
                    return convertView;
                }
                
                static class ViewHolder {
                    TextView unitView;
                    TextView quantityView;
                }
                
                }
                

                最初,我嘗試使用此代碼顯示對話框:

                Initially, I tried this code to display the dialog box:

                private void showDialog(){
                    final Dialog dialog = new Dialog(this);
                    dialog.setContentView(R.layout.dialog_main);
                
                
                    dialog.show();
                }
                

                但它只顯示一個空白行,很明顯我沒有正確填充它.

                But it only shows, one blank row, it is very clear that I am not populating it properly.

                有什么想法嗎?此外,我可以在 showDialog() 函數(shù)中填充對話框,因為我在同一個 java 類中也有我想要填充的數(shù)據(jù).

                Any ideas anyone? Also, I can populate the dialog boxes in the showDialog() function since I also have the data I want to populate with in the same java class.

                推薦答案

                你在做以下事情嗎?您將需要擴充布局文件 dialog_main,找到 ListView,為其設(shè)置適配器和 OnItemClickListener.在此之后,您可以使用對話框的 setContentView(View) 方法來獲取要顯示的列表.

                Are you doing the following? You will need to inflate the layout file dialog_main, find the ListView, set an adapter and an OnItemClickListener for it. After this, you can use the dialog's setContentView(View) method to get the list to display.

                private void showDialog(){
                
                    final Dialog dialog = new Dialog(this);
                
                    View view = getLayoutInflater().inflate(R.layout.dialog_main, null);
                
                    ListView lv = (ListView) view.findViewById(R.id.custom_list);
                
                    // Change MyActivity.this and myListOfItems to your own values
                    CustomListAdapterDialog clad = new CustomListAdapterDialog(MyActivity.this, myListOfItems);
                
                    lv.setAdapter(clad);
                
                    lv.setOnItemClickListener(........);
                
                    dialog.setContentView(view);
                
                    dialog.show();
                
                }
                

                順便說一句,您的適配器看起來還不錯.它不起作用,因為你沒有給它任何工作.

                By the way, your adapter looks alright. It isn't working because you're not giving it anything to work on.

                這篇關(guān)于Android - 在自定義對話框中正確執(zhí)行自定義列表視圖的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                相關(guān)文檔推薦

                Get user#39;s current location using GPS(使用 GPS 獲取用戶的當(dāng)前位置)
                IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網(wǎng)絡(luò)提供商)
                Get current location during app launch(在應(yīng)用啟動期間獲取當(dāng)前位置)
                locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)

                <tfoot id='K7Bo2'></tfoot>
              1. <legend id='K7Bo2'><style id='K7Bo2'><dir id='K7Bo2'><q id='K7Bo2'></q></dir></style></legend>
              2. <small id='K7Bo2'></small><noframes id='K7Bo2'>

                <i id='K7Bo2'><tr id='K7Bo2'><dt id='K7Bo2'><q id='K7Bo2'><span id='K7Bo2'><b id='K7Bo2'><form id='K7Bo2'><ins id='K7Bo2'></ins><ul id='K7Bo2'></ul><sub id='K7Bo2'></sub></form><legend id='K7Bo2'></legend><bdo id='K7Bo2'><pre id='K7Bo2'><center id='K7Bo2'></center></pre></bdo></b><th id='K7Bo2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='K7Bo2'><tfoot id='K7Bo2'></tfoot><dl id='K7Bo2'><fieldset id='K7Bo2'></fieldset></dl></div>

                        <bdo id='K7Bo2'></bdo><ul id='K7Bo2'></ul>

                            <tbody id='K7Bo2'></tbody>
                          主站蜘蛛池模板: 91资源在线观看 | 美女黄色在线观看 | 免费一区| 影音先锋中文字幕在线观看 | 精品中文字幕久久 | 成人精品一区二区三区中文字幕 | 欧美xxxx在线 | 蜜臀网站| 成人妇女免费播放久久久 | 免费观看的av毛片的网站 | 中文字幕av高清 | 国产精品视频网 | 91色在线 | 精品中文在线 | 精品久久精品 | 亚洲国产欧美日韩 | 欧美一级视频免费看 | 精品国产不卡一区二区三区 | 成人免费看黄网站在线观看 | 视频一区中文字幕 | 欧美日韩国产在线观看 | 国产精品夜间视频香蕉 | 日韩欧美国产精品一区 | 久久久久成人精品亚洲国产 | 欧美国产日韩一区二区三区 | 九九免费视频 | 91精品国产91久久久久青草 | 欧美影院| 日日操夜夜操天天操 | 亚洲自拍一区在线观看 | 美女视频h | 亚洲激情综合 | 区一区二区三在线观看 | 国产亚洲www | 免费中文字幕 | 久久精品国产99国产精品 | 久久国产欧美日韩精品 | 一区二区三区在线免费观看视频 | 99久久精品国产一区二区三区 | 日日夜夜影院 | 一级特黄在线 |