當前位置:首頁 » 安卓系統 » android動態獲取id

android動態獲取id

發布時間: 2023-11-14 04:08:13

Ⅰ android 怎麼獲取控制項的id

控制項的id是自己在xml中定義的, 可以通過R.id.來得到, 如果是view的話,可以直接調用view.getId()即可得到該ID了

Ⅱ android動態創建的Textview怎麼獲取或者給他設置一個ID

ID本身是個int類型的,就算設置也只能給一個隨機不重復的int數字,但是如果想要通過字元串去實現,用個HashMap把鍵值對存下來

final static HashMap<String, Integer> listView = new HashMap<String, Integer>();

賦值ID linearLayout.setId(唯一id);

鍵值對 listView.put(字元串id, 前邊定義的唯一int ID);

獲取:

public static Integer getViewIdById(String id){
if (listView.containsKey(id))
return listView.get(id);
else
return -1;
}

Ⅲ 安卓開發中如何獲取userId

當手機使用者(即User)下載你(即開發者)的應用程序,在安裝(Install)時,Android就會給予一個UID。
在Package.list(放在/data/system)中存放著系統各個程序的user id。你可以這樣獲取:
PackageManager pm = getPackageManager();
ApplicationInfo ai = pm.getApplicationInfo("com.gesoft.bit.lavendercloud", PackageManager.GET_ACTIVITIES);
Log.d("!!", "!!" + ai.uid);

這個uid和linux下的uid含義可不同哦。

Android一直是單用戶操作系統,在Android 4.2中才加入了多用戶支持。

Ⅳ Android下如何取當前獲得焦點的控制項的ID

Android如何獲取動態添加控制項的id:
RelativeLayout mainLayout = (RelativeLayout)findViewById(R.id.relaGameZhaiGuoZi);
imgApple2 = new ImageView(this);
imgApple2.setImageResource(R.drawable.app);
imgApple2.setId(110);
imgApple2.setOnClickListener(this);
RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp1.leftMargin=30;
lp1.topMargin = 100;
碼此mainLayout.addView(imgApple2,lp1);
View類裡面有一個findFocus的成員函數,作用早模梁相當於找到以當前View為根的view層次結構中,獲陸運得當前輸入焦點的view 。

Ⅳ Android怎麼獲取進程Id

通過linux命令來獲取進程ID範例代碼:

java">ProcesspsProcess=Runtime.getRuntime().exec("sh");
DataOutputStreamout=newDataOutputStream(psProcess.getOutputStream());
InputStreamis=psProcess.getInputStream();
out.writeBytes("ps|grep'vpnloader'|cut-c10-14 ");
out.writeBytes("ps ");
out.flush();
try{
psProcess.waitFor();
}catch(InterruptedExceptione){
//TODOAuto-generatedcatchblock
e.printStackTrace();}

if(is.read()!=0)
{
bytefirstByte=(byte)is.read();
intavailable=is.available();
byte[]characters=newbyte[available+1];
characters[0]=firstByte;
is.read(characters,1,available);
Stringre=newString(characters);
熱點內容
河南科技大學期末編譯原理試題 發布:2025-07-12 19:53:17 瀏覽:46
電腦中的微信聊天記錄在哪裡存儲 發布:2025-07-12 19:47:22 瀏覽:944
蘋果6sp怎麼設置密碼 發布:2025-07-12 19:28:50 瀏覽:547
電視下架緩存的還能看嗎 發布:2025-07-12 19:14:12 瀏覽:444
安卓平板微軟平板和蘋果哪個好 發布:2025-07-12 19:09:37 瀏覽:413
資料庫地區 發布:2025-07-12 19:05:41 瀏覽:395
如何檢查vds腳本 發布:2025-07-12 19:04:24 瀏覽:909
命令行編譯vs2013 發布:2025-07-12 19:01:22 瀏覽:809
c語言輸出所有素數 發布:2025-07-12 19:01:19 瀏覽:659
查電費賬號密碼多少 發布:2025-07-12 18:56:19 瀏覽:545