我试图操纵从BaseAdapter扩展的ImageAdapter类的布局按钮。
这是我的适配器类:
public class ImageAdapterAvatar extends BaseAdapter {
public ImageAdapterAvatar(Context context) {
this.context = context;
}
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View gridView = inflater.inflate(R.layout.avatar, null);
//do things with my gridwiew
View bouttonView = inflater.inflate(R.layout.activity_which_contain_my_button,null);
Button bouttonValidate = (Button) bouttonView.findViewById(R.id.buttonValidate);
}
}
和我的活动代码
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_which_contain_my_button);
fragmentAdaptateur = new ImageAdapterAvatar(this);
gridView工作,我可以做我想要的,但按钮不是,我可以得到元素,但当我尝试操纵像:
bouttonValidate.setText("hello world");
我没有回应。
需要帮助~~
答案 0 :(得分:0)
检查一下,可能有帮助......
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
// templateUrl: "app/test.html"
templateUrl: "WEB-INF/pages/blocks/test.jsp"
})
export class AppComponent { }
答案 1 :(得分:0)
最后我用这个
制作了这个伎俩Activity activity= (Activity) context;
Button bouttonValidate = (Button) activity.findViewById(R.id.buttonValidate);
实际上我可以简单地将我的上下文转换为活动,然后从活动中调用findViewById方法,然后操纵布局元素