編輯:關於android開發
這個例子非常簡單,簡單到一個初學者都能隨便開發出來,今天的目的僅僅只是為了將效果實現出來,如果想深入這裡有幾篇非常不錯的博客:
http://blog.csdn.net/t12x3456/article/details/7828620
ExpandableListView講解
http://www.apkbus.com/thread-124715-1-1.html
和使用listview一樣,我們這裡需要繼承一個適配器,叫做BaseExpandListAdapter;然後重寫幾個父類的方法
package com.example.uitest;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
public class TreeAdapter extends BaseExpandableListAdapter{
Context context;
public TreeAdapter(Context context) {
super();
this.context = context;
}
@Override
public Object getChild(int arg0, int arg1) {
return 0;
}
@Override
public long getChildId(int arg0, int arg1) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getChildView(int arg0, int arg1, boolean arg2, View v,
ViewGroup arg4) {
v = LayoutInflater.from(context).inflate(R.layout.item2, null);
return v;
}
@Override
public int getChildrenCount(int arg0) {
// TODO Auto-generated method stub
return 3;
}
@Override
public Object getGroup(int arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getGroupCount() {
return 3;
}
@Override
public long getGroupId(int arg0) {
return 0;
}
@Override
public View getGroupView(int arg0, boolean arg1, View v, ViewGroup vgs) {
v = LayoutInflater.from(context).inflate(R.layout.item_autocomplete, null);
return v;
}
@Override
public boolean hasStableIds() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isChildSelectable(int arg0, int arg1) {
// TODO Auto-generated method stub
return false;
}
}
這裡我們只操作了四個函數,分別是:
public int getChildrenCount(int arg0) ;//獲取二級列表的子布局總記錄,也就是行數
public int getGroupCount();//獲取一級列表的行數
public View getChildView(int arg0, int arg1, boolean arg2, View v,
ViewGroup arg4);//獲取二級列表的資源布局
public View getGroupView(int arg0, boolean arg1, View v, ViewGroup vgs);//獲取一級列表的行數
最後將適配器加載至ExpandableListView中:
ExpandableListView view = (ExpandableListView)findViewById(R.id.elv);
TreeAdapter adapter = new TreeAdapter(getApplicationContext());
view.setAdapter(adapter);
主布局xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ExpandableListView
android:id="@+id/elv"
android:layout_width="fill_parent"
android:groupIndicator="@null"
android:layout_height="wrap_content"></ExpandableListView>
</LinearLayout>
這是最濃縮版了大家應該很快可以懂;
Android中使用Notification實現進度通知欄(示例三),notification進度條我們在使用APP的過程中,軟件會偶爾提示我們進行版本更新,我們點擊確認
49.Android 各種Span 49.Android 各種Span Android 各種Span 前言 SpannableStringBuilder URLSpan
viewflipper動畫切換屏幕,viewflipper動畫切換 整個項目的 package com.example.viewflipper; imp
自定義開關ToggleButton的使用,開關togglebutton【代碼】: toggleMe.setOnCheckedChangeListener(new Comp