我是这样创建ListView和listener的:
public ListView mainactivitylist;
View view=this.getLayoutInflater().inflate(R.layout.activity_incomingagreement_list, null);
mainactivitylist=view.findViewById(R.id.待审批合同列表);
mainactivitylist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position==0){
try {
if ("营销管理部".equals(GetUserPermission(loginusername))){
Bundle bundle2=new Bundle();
bundle2.putString("loginusername", loginusername);
Intent intent2=new Intent(MainActivity.this,NewAgreement.class);
intent2.putExtras(bundle2);
startActivity(intent2);
}else {
Toast.makeText(MainActivity.this, "当前用户没有发起合同的权限,只有营销管理部的用户才拥有此权限。",
Toast.LENGTH_SHORT).show();
}
} catch (IOException e) {
e.printStackTrace();
}
}
if (position==1) {
Intent incomingagreementlist=new Intent(MainActivity.this,IncomingAgreementList.class);
startActivity(incomingagreementlist);
}
if (position==2){
new Thread(new Runnable() {
@Override
public void run() {
Message message=handleruserinfo.obtainMessage();
handleruserinfo.sendMessage(message);
}
}).start();
}
}
});
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="mainactivitylistview">
<item>发起新合同</item>
<item>待审批合同列表</item>
<item>当前用户信息</item>
</string-array>
</resources>
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:entries="@array/mainactivitylistview"/>
进入程序后,列表内容显示是正常的,就是点击列表项没有任何反应,也没报任何异常,程序也没崩溃。
我并没有在ListView里添加按钮或复选框什么的。
请问怎么解决?
1.先不要写判断,直接写在onitemclick里面看看有没有接收到点击时间
2.没有接收到,看看是不是子布局点击事件冲突
3.看看是不是子控件没有下发事件