Nob*_*oby 53 android listadapter android-activity
我尝试将context活动传递到适配器然后我尝试context.finish();但它给我一个错误就像The method finish() is undefined for the type Context
小智 7
尝试使用以下代码:
public YourAdapterName(......,Context context){
...
this.myContext=context;
}
Run Code Online (Sandbox Code Playgroud)
在你的适配器getView()
btn.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
((YourActivityName)myContext).yourDesiredMethod();
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
46599 次 |
| 最近记录: |