0
ExpandableListview에서 그룹을 클릭했을 때 활동을 표시하고 싶습니다. onGroupExpand에 인 텐트를 추가하여 하위 목록이 아닌 새 활동을 열려고했습니다. 그러나 활동을 열 때만. 그룹을 클릭하면 아래에 표시하고 싶습니다. 여기로하기 Aleks 당신이 최고 애니메이션이나 숨기고에 다른 레이아웃을 보여 가시성을 사용하여 바닥의 어떤 종류를 사용할 수 있지만 모든 활동은 하나의 레이아웃을 포함 할 수 있기 때문에 불가능했다ExpandableListView가 아래 새 활동을 엽니 다.
package pack.ExpandableListtwo;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.app.ExpandableListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.SimpleExpandableListAdapter;
public class ExpandableListDemo extends ExpandableListActivity {
@SuppressWarnings("unchecked")
public void onCreate(Bundle savedInstanceState) {
try {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
SimpleExpandableListAdapter expListAdapter =
new SimpleExpandableListAdapter(
this,
createGroupList(),
R.layout.group_row,
new String[] { "Group Item" },
new int[] { R.id.row_name },
createChildList(),
R.layout.child_row,
new String[] {"Sub Item"},
new int[] { R.id.grp_child}
);
setListAdapter(expListAdapter);
}catch(Exception e){
System.out.println("Errrr +++ " + e.getMessage());
}
}
/* Creating the Hashmap for the row */
@SuppressWarnings("unchecked")
private List createGroupList() {
ArrayList result = new ArrayList();
for(int i = 0 ; i < 3 ; ++i) { // 3 groups........
HashMap m = new HashMap();
m.put("Group Item","Group Item " + i); // the key and it's value.
result.add(m);
}
return (List)result;
}
/* creatin the HashMap for the children */
@SuppressWarnings("unchecked")
private List createChildList() {
ArrayList result = new ArrayList();
for(int i = 0 ; i < 3 ; ++i) { // this -3 is the number of groups(Here it's fifteen)
/* each group need each HashMap-Here for each group we have 3 subgroups */
ArrayList secList = new ArrayList();
Intent intent = new Intent(getApplicationContext(),
MainActivity.class);
startActivity(intent);
result.add(secList);
}
return result;
}
public void onContentChanged () {
System.out.println("onContentChanged");
super.onContentChanged();
}
/* This function is called on each child click */
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,int childPosition,long id) {
return true;
}
/* This function is called on expansion of the group */
public void onGroupExpand (int groupPosition) {
try{
System.out.println("Group exapanding Listener => groupPosition = " + groupPosition);
}catch(Exception e){
System.out.println(" groupPosition Errrr +++ " + e.getMessage());
Intent intent = new Intent(getApplicationContext(),
MainActivity.class);
startActivity(intent);
}
}
}
내가 묻는 바를 정확히 이해했다면, 화면에서 기존 활동을 대체하는 대신 _ 화면의 일부인 _을 열려고합니다. Android에서는이 기능을 사용할 수 없습니다. 목록보기 아래에 무언가를 보여주고 싶다면 조각에 대해 읽어보십시오. –