当前位置:首页 » 安卓系统 » 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 20:50:17 浏览:799
对比价格的插件或脚本 发布:2025-07-12 20:49:34 浏览:184
android底部抽屉 发布:2025-07-12 20:40:40 浏览:318
php变量括号 发布:2025-07-12 20:40:36 浏览:176
服务器防火墙ip访问限制 发布:2025-07-12 20:35:36 浏览:197
强连通分量算法 发布:2025-07-12 20:12:40 浏览:611
河南科技大学期末编译原理试题 发布: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 浏览:445