当前位置:首页 » 安卓系统 » 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);
热点内容
c语言fread返回值 发布:2025-07-12 16:57:32 浏览:678
王者荣耀在哪里显示账号密码 发布:2025-07-12 16:36:42 浏览:898
打包sql数据库 发布:2025-07-12 16:19:27 浏览:796
php日志查看 发布:2025-07-12 16:12:10 浏览:214
ftp目录映射为本地盘符 发布:2025-07-12 16:06:59 浏览:645
nas存储百科 发布:2025-07-12 16:03:17 浏览:126
python的sort函数 发布:2025-07-12 15:53:21 浏览:50
ensp服务器怎么设置web根目录 发布:2025-07-12 15:47:56 浏览:286
安卓怎么设置二卡发信息 发布:2025-07-12 15:43:50 浏览:743
如何看到无线密码 发布:2025-07-12 15:43:13 浏览:677