如何在不同的xml布局中解决onclcik监听器问题?

时间:2015-05-06 07:00:38

标签: android-listview onclicklistener

在android中我设计了一个带有两个按钮的列表视图,现在我想在一个按钮上设置 onclicklistener 但在不同的类中。所以我写了一个代码

View view1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_installation);
        Datalist=(ListView)findViewById(R.id.installationList);

        ButtonLayout ViewButton=new ButtonLayout();


        ArrayList<HashMap<String, String>> arl = (ArrayList<HashMap<String, String>>) getIntent().getSerializableExtra("hashMap");


       SimpleAdapter adapter = new SimpleAdapter(
                Installation.this, arl,
                R.layout.activity_button_layout, new String[]
                        {   
                        TAG_Title,TAG_URL 
                         }, new int[] { 
                        R.id.InnerText1,R.id.URL1 });


       LayoutInflater layoutInflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        Datalist.setAdapter(adapter);


        view1 = layoutInflater.inflate(R.layout.activity_button_layout,null);


        ViewButton.ClickButton = (ImageButton)view1.findViewById(R.id.ImageButton01);
        ViewButton.ClickButton.setOnClickListener(new View.OnClickListener(){
          public void onClick(View view) {
              Log.i("Edit Button Clicked", "*********");
              }
            });

但是当我运行我的应用程序然后它被停止时,你能帮助我吗

logcat的 enter image description here

0 个答案:

没有答案