Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的 android 应用程序中,我需要将一些数据从 Activity 类传递给 View 类。但问题是,我不能打电话
protected void onActivityResult(int requestCode, int resultCode, Intent data)
View 类中的方法。还有另一种方法可以做到这一点吗?
在您的扩展View类中
View
1) 声明变量
Bundle bundle=new Bundle();
2)把这个方法
public void setData(Bundle data) { bundle =data; }
从活动访问
View mView =new View(YourActivity.this); mView.setData(new Bundle());