![【移動應(yīng)用開發(fā)技術(shù)】android的ExpandableListView_第1頁](http://file4.renrendoc.com/view/26e4aac15b9c6e2c46a8c4871ea87ad7/26e4aac15b9c6e2c46a8c4871ea87ad71.gif)
![【移動應(yīng)用開發(fā)技術(shù)】android的ExpandableListView_第2頁](http://file4.renrendoc.com/view/26e4aac15b9c6e2c46a8c4871ea87ad7/26e4aac15b9c6e2c46a8c4871ea87ad72.gif)
![【移動應(yīng)用開發(fā)技術(shù)】android的ExpandableListView_第3頁](http://file4.renrendoc.com/view/26e4aac15b9c6e2c46a8c4871ea87ad7/26e4aac15b9c6e2c46a8c4871ea87ad73.gif)
![【移動應(yīng)用開發(fā)技術(shù)】android的ExpandableListView_第4頁](http://file4.renrendoc.com/view/26e4aac15b9c6e2c46a8c4871ea87ad7/26e4aac15b9c6e2c46a8c4871ea87ad74.gif)
![【移動應(yīng)用開發(fā)技術(shù)】android的ExpandableListView_第5頁](http://file4.renrendoc.com/view/26e4aac15b9c6e2c46a8c4871ea87ad7/26e4aac15b9c6e2c46a8c4871ea87ad75.gif)
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
【移動應(yīng)用開發(fā)技術(shù)】android的ExpandableListView
activity_main.xml<RelativeLayout
xmlns:android="/apk/res/android"
xmlns:tools="/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.expandablelistview.MainActivity"
>
<ExpandableListView
android:id="@+id/ExpandableListView1_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:groupIndicator="@null"
>
</ExpandableListView>
</RelativeLayout>
<!--
android:groupIndicator="@null"去掉自帶的箭頭圖標(biāo)
-->group_item.xml<?xml
version="1.0"
encoding="utf-8"?>
<LinearLayout
xmlns:android="/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:id="@+id/p_w_picpathViewgroup_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
/>
<TextView
android:id="@+id/textViewgroup_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>child_item.xml<?xml
version="1.0"
encoding="utf-8"?>
<LinearLayout
xmlns:android="/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:id="@+id/p_w_picpathViewchild_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:padding="10dp"
/>
<TextView
android:id="@+id/textViewchild_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sdfds"
android:padding="10dp"
/>
</LinearLayout>MainActivitypackage
com.example.expandablelistview;
import
android.app.Activity;
import
android.os.Bundle;
import
android.view.Menu;
import
android.view.MenuItem;
import
android.view.View;
import
android.view.ViewGroup;
import
android.widget.BaseExpandableListAdapter;
import
android.widget.ExpandableListView;
import
android.widget.ImageView;
import
android.widget.TextView;
public
class
MainActivity
extends
Activity
{
private
ExpandableListView
expandableListView;
@Override
protected
void
onCreate(Bundle
savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
expandableListView=(ExpandableListView)
findViewById(R.id.ExpandableListView1_1);
expandableListView.setAdapter(new
MyExpandableListAdapter());
}
@Override
public
boolean
onCreateOptionsMenu(Menu
menu)
{
//
Inflate
the
menu;
this
adds
items
to
the
action
bar
if
it
is
present.
getMenuInflater().inflate(R.menu.main,
menu);
return
true;
}
@Override
public
boolean
onOptionsItemSelected(MenuItem
item)
{
//
Handle
action
bar
item
clicks
here.
The
action
bar
will
//
automatically
handle
clicks
on
the
Home/Up
button,
so
long
//
as
you
specify
a
parent
activity
in
AndroidManifest.xml.
int
id
=
item.getItemId();
if
(id
==
R.id.action_settings)
{
return
true;
}
return
super.onOptionsItemSelected(item);
}
class
MyExpandableListAdapter
extends
BaseExpandableListAdapter{
private
String[]
skills
=
new
String[]{
"WORD",
"EXCEL",
"EMAIL",
"PPT"
};
private
String[][]
groups
=
new
String[][]{
{"文檔編輯",
"文檔排版",
"文檔處理",
"文檔打印"},
{"表格編輯",
"表格排版",
"表格處理",
"表格打印"},
{"收發(fā)郵件",
"管理郵箱",
"登錄登出",
"注冊綁定"},
{"演示編輯",
"演示排版",
"演示處理",
"演示打印"},
};
@Override
public
int
getGroupCount()
{
//
TODO
Auto-generated
method
stub
return
skills.length;
}
//二級列表的數(shù)量
@Override
public
int
getChildrenCount(int
groupPosition)
{
//
TODO
Auto-generated
method
stub
return
groups[groupPosition].length;
}
//返回每一組的對象
@Override
public
Object
getGroup(int
groupPosition)
{
//
TODO
Auto-generated
method
stub
return
skills[groupPosition];
}
//返回每組中的列表項
@Override
public
Object
getChild(int
groupPosition,
int
childPosition)
{
//
TODO
Auto-generated
method
stub
return
groups[groupPosition][childPosition];
}
@Override
public
long
getGroupId(int
groupPosition)
{
//
TODO
Auto-generated
method
stub
return
groupPosition;
}
@Override
public
long
getChildId(int
groupPosition,
int
childPosition)
{
//
TODO
Auto-generated
method
stub
return
childPosition;
}
@Override
public
boolean
hasStableIds()
{
//
TODO
Auto-generated
method
stub
return
true;
}
@Override
public
View
getGroupView(int
groupPosition,
boolean
isExpanded,
View
convertView,
ViewGroup
parent)
{
//
TODO
Auto-generated
method
stub
if(convertView==null){
convertView=getLayoutInflater().inflate(R.layout.group_item,
null);
}
ImageView
p_w_picpathView=(ImageView)
convertView.findViewById(R.id.p_w_picpathViewgroup_1);
TextView
textView=(TextView)
convertView.findViewById(R.id.textViewgroup_1);
p_w_picpathView.setImageResource(R.drawable.ic_launcher);
textView.setText(skills[groupPosition]);
return
convertView;
}
@Override
public
View
getChildView(int
groupPosition,
int
childPosition,
boolean
isLastChild,
View
convertView,
ViewGroup
pa
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025至2031年中國經(jīng)編干發(fā)巾行業(yè)投資前景及策略咨詢研究報告
- 2025年普通婦檢床項目可行性研究報告
- 2025年急診室設(shè)備項目可行性研究報告
- 2025至2031年中國壓力電波黑膠管行業(yè)投資前景及策略咨詢研究報告
- 2025年衛(wèi)生間用紡織品項目可行性研究報告
- 廣西2025年廣西醫(yī)科大學(xué)第二附屬醫(yī)院護(hù)理人員招聘50人筆試歷年參考題庫附帶答案詳解
- 2025至2030年中國銀行賬戶管理系統(tǒng)數(shù)據(jù)監(jiān)測研究報告
- 2025至2030年中國金屬鮑爾環(huán)填料數(shù)據(jù)監(jiān)測研究報告
- 2025至2030年移動式電腦絎縫機(jī)項目投資價值分析報告
- 2025至2030年中國胡蘿卜果蔬汁數(shù)據(jù)監(jiān)測研究報告
- 中學(xué)學(xué)校2024-2025學(xué)年教師發(fā)展中心工作計劃
- app 購買合同范例
- 小班期末家長會-雙向奔赴 共育花開【課件】
- 礦山生態(tài)修復(fù)工程不穩(wěn)定斜坡治理工程設(shè)計
- 2024年江西省高考物理試卷(含答案解析)
- 頸部瘢痕攣縮畸形治療
- 貴州省貴陽市2023-2024學(xué)年五年級上學(xué)期語文期末試卷(含答案)
- 規(guī)劃課題申報范例:俄羅斯教育改革研究(附可修改技術(shù)路線圖)
- 運輸企業(yè)安全事故報告調(diào)查處理制度(簡單版5篇)
- 倉庫貨物安全管理
- 端午做香囊課件
評論
0/150
提交評論