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

AlertDialog 中的多個(gè) EditText 對(duì)象

Multiple EditText objects in AlertDialog(AlertDialog 中的多個(gè) EditText 對(duì)象)
本文介紹了AlertDialog 中的多個(gè) EditText 對(duì)象的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

我正在為大學(xué)做一個(gè)項(xiàng)目,讓用戶在地圖上放置一個(gè)點(diǎn),然后為覆蓋對(duì)象設(shè)置標(biāo)題和描述.問(wèn)題是,第二個(gè) EditText 框覆蓋了第一個(gè).這是我的對(duì)話框代碼.

I'm working on a project for college that will let a user place a point on a map and then set the title and description for the overlay object. The problem is, the second EditText box overwrites the first one. Here is my code for the dialog box.

//Make new Dialog
AlertDialog.Builder dialog = new AlertDialog.Builder(mapView.getContext());
dialog.setTitle("Set Target Title & Description");
dialog.setMessage("Title: ");

final EditText titleBox = new EditText(mapView.getContext());
dialog.setView(titleBox);

dialog.setMessage("Description: ");
final EditText descriptionBox = new EditText(mapView.getContext());
dialog.setView(descriptionBox);

任何幫助將不勝感激!謝謝!

Any help would be appreciated!! Thanks!

推薦答案

一個(gè)Dialog只包含一個(gè)根View,這就是為什么setView()會(huì)覆蓋第一個(gè)EditText.解決方案很簡(jiǎn)單,將所有內(nèi)容放在一個(gè) ViewGroup 中,例如 LinearLayout:

A Dialog only contains one root View, that's why setView() overwrites the first EditText. The solution is simple put everything in one ViewGroup, for instance a LinearLayout:

Context context = mapView.getContext();
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);

// Add a TextView here for the "Title" label, as noted in the comments
final EditText titleBox = new EditText(context);
titleBox.setHint("Title");
layout.addView(titleBox); // Notice this is an add method

// Add another TextView here for the "Description" label
final EditText descriptionBox = new EditText(context);
descriptionBox.setHint("Description");
layout.addView(descriptionBox); // Another add method

dialog.setView(layout); // Again this is a set method, not add

(這是一個(gè)基本示例,但它應(yīng)該可以幫助您入門(mén).)

(This is a basic example, but it should get you started.)

您應(yīng)該注意 setadd 方法之間的命名差異.setView() 只保存一個(gè)View,setMessage() 也一樣.事實(shí)上,這對(duì)于每個(gè) set 方法都應(yīng)該是正確的,您正在考慮的是 add 命令.add 方法是累積的,它們會(huì)構(gòu)建一個(gè)您推送的所有內(nèi)容的列表,而 set 方法是單數(shù)的,它們會(huì)替換現(xiàn)有數(shù)據(jù).

You should take note of the nomenclature difference between a set and add method. setView() only holds one View, the same is similar for setMessage(). In fact this should be true for every set method, what you're thinking of are add commands. add methods are cumulative, they build a list of everything you push in while set methods are singular, they replace the existing data.

這篇關(guān)于AlertDialog 中的多個(gè) EditText 對(duì)象的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Cut, copy, paste in android(在android中剪切、復(fù)制、粘貼)
android EditText blends into background(android EditText 融入背景)
Change Line Color of EditText - Android(更改 EditText 的線條顏色 - Android)
EditText showing numbers with 2 decimals at all times(EditText 始終顯示帶 2 位小數(shù)的數(shù)字)
Changing where cursor starts in an expanded EditText(更改光標(biāo)在展開(kāi)的 EditText 中的開(kāi)始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問(wèn)題)
主站蜘蛛池模板: 国产精品自拍第一页 | 国产精品99999 | 欧美精品一二三区 | 国产精品6 | 国产传媒av | av网站在线免费观看 | 久久99精品久久久久久琪琪 | 一级国产片 | 欧美一级淫片bbb一84 | 亚洲高清免费视频 | 国产一区精品在线观看 | av在线免费观看网站 | 国产一级二级片 | 性做久久久久久 | 日韩爱爱视频 | 国产三级视频在线 | 三级黄色片 | 一区二区三区四区在线播放 | 一二三四区在线观看 | 久久精品一区二区三区四区 | 国产成人午夜高潮毛片 | 91中文在线 | 成人短视频在线观看 | 国产精品国产精品国产专区不卡 | 中文字幕在线免费看 | 亚洲激情另类 | 日本香蕉视频 | 中文字幕亚洲综合 | av老司机在线观看 | 国产精品99久久久久久久久久久久 | 欧美日韩在线播放 | 国产精品1区2区 | 欧美一级特黄aaaaaa | 久久伊人av| 国产又粗又猛又爽又黄 | 可以免费看av的网站 | 亚洲精品乱码久久久久久动漫 | 成人免费看片98欧美 | av手机在线观看 | 国产午夜激情 | 久久精品一区二区三区四区五区 |