嘿,我设计了一个帮助活动,我有父母(groupItems),每个都有一个特定的孩子..到目前为止没有问题。但是,默认情况下,可扩展列表视图的childItems是可点击的,以便在您点击它们时闪烁。而这正是我想要避免的!这是我用儿童的布局ExpandableListActivity使childItems不可点击
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/grp_child"
android:paddingLeft="20dp"
android:textSize="15dp"
android:textStyle="normal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
这里是我的源代码的一切变得充满内容(这工作):
public class HelpActivity extends ExpandableListActivity {
private static final String TAG = "HelpActivity";
private static final String PARENT = "parent";
private static final String CHILD = "child";
private List<HashMap<String,String>> parents;
private List<List<HashMap<String, String>>> childs;
public void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "Instantiated new " + this.getClass());
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
parents = createParentList();
childs = createChildList();
SimpleExpandableListAdapter expListAdapter = new SimpleExpandableListAdapter(
this,
parents, // Describing data of group List
R.layout.help_group_item, // Group item layout XML.
new String[] {PARENT}, // the key of group item.
new int[] {R.id.row_name}, // ID of each group item.-Data under the key goes into this TextView.
childs, // childData describes second-level entries.
R.layout.help_child_item, // Layout for sub-level entries(second level).
new String[] {CHILD}, // Keys in childData maps to display.
new int[] {R.id.grp_child} // Data under the keys above go into these TextViews.
);
setListAdapter(expListAdapter); // setting the adapter in the list.
}
/* Creating the Hashmap for the row */
private List<HashMap<String,String>> createParentList() {
ArrayList<HashMap<String,String>> result = new ArrayList<HashMap<String,String>>();
HashMap<String,String> m = new HashMap<String,String>();
m.put(PARENT,getResources().getString(R.string.help_parent_1));
result.add(m);
m = new HashMap<String,String>();
m.put(PARENT,getResources().getString(R.string.help_parent_2));
result.add(m);
m = new HashMap<String,String>();
m.put(PARENT,getResources().getString(R.string.help_parent_3));
result.add(m);
return result;
}
/* creatin the HashMap for the children */
private List<List<HashMap<String, String>>> createChildList() {
ArrayList<List<HashMap<String, String>>> result = new ArrayList<List<HashMap<String, String>>>();
for (int i=0;i<parents.size();i++){
HashMap<String, String> sec = parents.get(i);
ArrayList<HashMap<String, String>> secChild = new ArrayList<HashMap<String, String>>();
HashMap<String,String> child = new HashMap<String,String>();
if(sec.containsValue(getResources().getString(R.string.help_parent_1))){
child.put(CHILD, getResources().getString(R.string.help_child_1));
}else if(sec.containsValue(getResources().getString(R.string.help_parent_2))){
child.put(CHILD, getResources().getString(R.string.help_child_2));
}else if(sec.containsValue(getResources().getString(R.string.help_parent_3))){
child.put(CHILD, getResources().getString(R.string.help_child_3));
}else if(sec.containsValue(getResources().getString(R.string.help_parent_4))){
child.put(CHILD, getResources().getString(R.string.help_child_4));
}
secChild.add(child);
result.add(secChild);
}
return result;
}
}
我想办是使textview的孩子不可点击:我已经尝试了textview属性,但没有人有效
android:clickable="false"
android:focusable="false"
android:enabled="false"
提前感谢任何可能有想法的人!
太好了,我已经想到它couldn不那么困难。刚试过 - 完美的作品。非常感谢你。 – Vossi 2012-02-28 14:13:54