TextView onClick() not working

后端 未结 5 1982
一生所求
一生所求 2020-12-16 09:48

here\'s my code for main.xml

 
 

        
5条回答
  •  难免孤独
    2020-12-16 10:21

    Use these

     all = (TextView) this.findViewById(R.id.viewall);
     pdf = (TextView) this.findViewById(R.id.pic);
    

    in on create and then set

    all.setOnclickListener(this) in oncreate() method too.Implement onClicklistener when it will show error. it will work like a charm.

    Edited

    TextView btn=(TextView) findViewById(R.id.accInfo);
    btn.setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                //DO you work here
            }
        });
    

    Setting Clicklistenner to TextView will automatically make it clickable so no need of

    android:clickable="true"
    

提交回复
热议问题