我想開發可擴展的應用Listview
手機號碼。我有一些Java代碼。但我不知道如何通過點擊Expandable ListView Child Item來調用手機號碼。比如,我想調用的「MD。納西爾·烏丁」手機號碼,「MD。塞利姆汗」,「拉蒂夫Sarker」,「法魯克·艾哈邁德」,「穆尼爾阿克拉姆」。我怎麼能叫上單擊可擴展列表視圖子項
這是我的Java代碼。
public class MainActivity extends Activity implements
SearchView.OnQueryTextListener, SearchView.OnCloseListener{
private SearchView search;
private MyListAdapter listAdapter;
private ExpandableListView myList;
private ArrayList<SectionItem> section = new ArrayList<SectionItem>();
ExpandableListView expandableList = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
expandableList=(ExpandableListView)findViewById(R.id.expandableList);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
search = (SearchView) findViewById(R.id.search);
search.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
search.setIconifiedByDefault(false);
search.setOnQueryTextListener(this);
search.setOnCloseListener(this);
//display the list
displayList();
//expand all Groups
expandAll();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
//method to expand all groups
private void expandAll() {
int count = listAdapter.getGroupCount();
for (int i = 0; i < count; i++){
myList.expandGroup(i);
}
}
//method to expand all groups
private void displayList() {
//display the list
loadSomeData();
//get reference to the ExpandableListView
myList = (ExpandableListView) findViewById(R.id.expandableList);
//create the adapter by passing your ArrayList data
listAdapter = new MyListAdapter(MainActivity.this, section);
//attach the adapter to the list
myList.setAdapter(listAdapter);
}
private void loadSomeData() {
ArrayList<EntryItem> items = new ArrayList<EntryItem>();
items = new ArrayList<EntryItem>();
section.add(new SectionItem("Family Member", items));
items.add(new EntryItem(R.drawable.ic_launcher, "Md. Nasir Uddin", "+88569842525", "+6525412698", "[email protected]", ""));
items.add(new EntryItem(R.drawable.ic_launcher, "Md. Selim Khan", "+7269874524", "+5825478569", "[email protected]", ""));
items.add(new EntryItem(R.drawable.ic_launcher, "Abdul Alim", "+2214569852", "+636598745", "[email protected]", ""));
items.add(new EntryItem(R.drawable.ic_launcher, "Abdul Mannan", "+3698521455", "+2569514457", "[email protected]", ""));
items = new ArrayList<EntryItem>();
section.add(new SectionItem("Friends List", items));
items.add(new EntryItem(R.drawable.ic_launcher, "Latif Sarker", "+8925824582", "+256992025", "[email protected]", ""));
items.add(new EntryItem(R.drawable.ic_launcher, "Hossain Ali", "+2547896514", "+354125824", "[email protected]", ""));
items.add(new EntryItem(R.drawable.ic_launcher, "Faruk Ahmed", "+3541269872", "+589314255", "[email protected]", ""));
items.add(new EntryItem(R.drawable.ic_launcher, "Ismail Hossain", "+86713373326", "+8625478965", "[email protected]", ""));
items = new ArrayList<EntryItem>();
section.add(new SectionItem("Relative List", items));
items.add(new EntryItem(R.drawable.ic_launcher, "Monir Akram", "+2536974144", "+2514796352", "[email protected]", ""));
items.add(new EntryItem(R.drawable.ic_launcher, "Aminul Islam", "+21478933544", "+36597452144", "[email protected]", ""));
items.add(new EntryItem(R.drawable.ic_launcher, "Kawsar Farhad", "+2145879325", "+25698472254", "[email protected]", ""));
}
@Override
public boolean onClose() {
listAdapter.filterData("");
expandAll();
return false;
}
@Override
public boolean onQueryTextChange(String query) {
listAdapter.filterData(query);
expandAll();
return false;
}
@Override
public boolean onQueryTextSubmit(String query) {
listAdapter.filterData(query);
expandAll();
return false;
}
}
不要標籤的Java代碼的JScript,因爲他們是不一樣的,正確格式化您的代碼,除非你正在使用SOMER DIFF庫,不添加到代碼標準API導入。 –