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

Android:以編程方式設(shè)置編輯文本或文本視圖 ID

Android: Set Edit text or text view id Programmatically(Android:以編程方式設(shè)置編輯文本或文本視圖 ID)
本文介紹了Android:以編程方式設(shè)置編輯文本或文本視圖 ID的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

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

我正在開發(fā)一個(gè)應(yīng)用程序,我在其中以編程方式創(chuàng)建一個(gè) Edittext:

I am developing an application in which i am creating an Edittext programmatically as :

EditText edText = new EditText(this);
edText.setId(1);
edText .setLayoutParams(new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,0f));
edText .setInputType(InputType.TYPE_CLASS_NUMBER);
edText.setHint("dsgsdgsgs");
tableLayout.addView(edText);

在這里,我通過 edText.setId(1); 行將編輯文本的 id 設(shè)置為1",以整數(shù)表示.

Here I am setting the id of the Edit text as "1" by the line edText.setId(1); in integer.

但我需要的是 - 我想以字符設(shè)置 ID,例如:

But what i need is - I want to set the ID in character as for example:

edText.setId("edittext_hello");

這樣我就可以通過該 ID 訪問它.我怎樣才能完成這項(xiàng)任務(wù),請(qǐng)幫忙.

So that i can access it via that id. How can i achieve this task please help.

推薦答案

不能將 id 設(shè)置為 String.您只能將整數(shù)分配為 Id.但是,如果您想使用 String 作為 id 以便于使用,那么 -在 res/values/ids.xml 文件中

You can't set id as a String. You can only assign integer as Id. But if you want to use String as id for the ease of use then - in res/values/ids.xml file

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <item name="edit_text_hello" type="id"/>

</resources>

然后將其用作:

edText.setId(R.id.edit_text_hello);

所以你可以做你需要的.

So you can do what you need.

這篇關(guān)于Android:以編程方式設(shè)置編輯文本或文本視圖 ID的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(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)在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: www.五月婷婷.com | 91欧美精品成人综合在线观看 | 蜜桃视频一区二区三区 | 一级做a| 伊人伊成久久人综合网站 | 亚洲精品aⅴ | 青娱乐自拍 | 精品日韩在线 | 亚洲女人天堂网 | 国产精品美女久久久久 | 祝你幸福电影在线观看 | 亚州毛片| 在线一区二区三区 | 四色成人av永久网址 | 国产成人午夜精品影院游乐网 | 久久9精品| 亚洲精品视频在线播放 | 欧美中文字幕在线 | 自拍中文字幕 | 欧美国产一区二区 | 日韩有码一区 | 欧美久久电影 | 99视频精品 | 欧美一区2区三区4区公司二百 | 欧美a在线 | caoporn国产精品免费公开 | 夜夜骑首页| 青娱乐国产 | 精品久久网 | 亚洲www| 国产成人精品一区二区三 | 美女天天操| av天天爽 | 久久专区 | 真人女人一级毛片免费播放 | 精品日韩一区 | 91精品国产乱码久久久 | 99国产在线 | 日本三级线观看 视频 | 久久99精品国产自在现线小黄鸭 | 国产精久久久久久久妇剪断 |