【发布时间】:2012-02-12 20:51:41
【问题描述】:
我已通过意图将我的资源 ID 传递给另一个类。然后我从意图中检索额外的内容并将其存储在一个 int 中。
现在我想将该 int 转换为视图或其他东西,以便我可以使用 getTag()?我尝试将它分配给 ImageView 但不断得到 NullPointer
通过:
int resourceId = v.getId();
Intent intent = new Intent(FetchMenu.this,FetchContent.class);
intent.putExtra("ResourceId",resourceId);
startActivity(intent);
收到:
int id;
Intent callingIntent = getIntent();
int getView= callingIntent.getIntExtra("ResourceId", 1);
id = getView;
这会打印到 logcat:
System.out.println("Resource ID: " + id);
Logcat:"Resource ID: 2131099660"
这给了我 NullPointer:
View v = (View)findViewById(id);
String str=(String) v.getTag();
System.out.println("Tag : " + str);
谢谢
【问题讨论】:
-
请问问题在哪里?
-
我想将接收到的 int 转换为某种视图?
标签: android android-intent int android-resources