当前位置:首页 » 安卓系统 » 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-09-07 06:18:10 浏览:87
android图片加载 发布:2025-09-07 06:10:48 浏览:493
mtp存储器 发布:2025-09-07 05:58:00 浏览:948
php继承类构造函数 发布:2025-09-07 05:57:07 浏览:703
指示数据库 发布:2025-09-07 05:55:45 浏览:628
如何恢复服务器系统 发布:2025-09-07 05:41:50 浏览:877
多个服务器如何集中管理 发布:2025-09-07 05:37:00 浏览:416
python读取文件行 发布:2025-09-07 05:34:14 浏览:662
mac版本ftp 发布:2025-09-07 05:27:09 浏览:531
条件编译是不是预处理环节 发布:2025-09-07 05:21:21 浏览:639