我一直在关注这个问题的其他人的答案,但到目前为止似乎没有任何工作.
目前,我有一个ExpandableListAdapter,它是根据SDK附带的一个示例构建的.至于显示数据我得到它正常工作,但我无法让onChildClick事件工作.我已经尝试将我的XML元素的focusable属性设置为false,但我仍然没有运气.
目前这是我的代码:
MainActivity.java
package com.example.expandablelisttest;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.ExpandableListView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ExpandableListView expandableListView = (ExpandableListView) findViewById(R.id.expandableListView1);
ExpandableListAdapter expandableAdapter = new ExpandableListAdapter();
expandableListView.setAdapter(expandableAdapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
ExpandableListAdapter.java
package com.example.expandablelisttest;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter; …Run Code Online (Sandbox Code Playgroud)