(context,beans,layoutId){@OverridepublicvoidsetValues(ViewHolderhelpe" />

欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

SlideExpandableListView滑動(dòng)顯示隱藏面板

系統(tǒng) 1823 0
快速實(shí)現(xiàn)一個(gè)滑動(dòng)顯示隱藏面板的ListView
SlideExpandableListView滑動(dòng)顯示隱藏面板


基本用法:
    
listView = (ListView) view.findViewById(R.id.listView);

protected void notifyDataSetChanged() {
		if (adapter == null) {
			adapter = new CommonAdapter<T>(context, beans, layoutId) {
				@Override
				public void setValues(ViewHolder helper, T item, int position) {
					createItem(helper, item, position);
				}
			};
			listView.setAdapter(new SlideExpandableListAdapter(adapter,
				R.id.expandable_toggle_button, R.id.expandable));
		} else {
			adapter.notifyDataSetChanged();
		}
	}

  


在你的item布局文件中需要有ID為expandable_toggle_button的把手,和ID為expandable的面板容器
典型的像下面這樣:
    
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="8dp"
        android:paddingRight="8dp"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/item_0"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|start"
            android:gravity="center"
            android:singleLine="true"
            android:text="訂單編號"
            android:textColor="@color/base_black"
            android:textSize="@dimen/font_middle" />

        <TextView
            android:id="@+id/item_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|end"
            android:gravity="center"
            android:paddingBottom="8dp"
            android:paddingTop="8dp"
            android:singleLine="true"
            android:text="進(jìn)場時(shí)間"
            android:textColor="@color/base_black"
            android:textSize="@dimen/font_middle" />
    </LinearLayout>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="8dp"
        android:paddingRight="8dp"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/item_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|start"
            android:gravity="center"
            android:singleLine="true"
            android:text="停車場名稱"
            android:textColor="@color/base_black"
            android:textSize="@dimen/font_middle" />

        <ImageView
            android:id="@+id/expandable_toggle_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|end"
            android:layout_marginRight="16dp"
            android:src="@drawable/bg_btn_more" />
    </FrameLayout>

    <LinearLayout
        android:id="@+id/expandable"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/base_gray"
        android:orientation="horizontal" 
        >

        <TextView
            android:id="@+id/btn_0"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:drawableTop="@drawable/bg_btn_0"
            android:gravity="center"
            android:singleLine="true"
            android:text="取消訂單"
            android:textColor="@android:color/white"
            android:textSize="@dimen/font_middle" />
        
        <TextView
            android:id="@+id/btn_1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:drawableTop="@drawable/bg_btn_0"
            android:gravity="center"
            android:singleLine="true"
            android:text="聯(lián)系對方"
            android:textColor="@android:color/white"
            android:textSize="@dimen/font_middle" />
        <TextView
            android:id="@+id/btn_2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:drawableTop="@drawable/bg_btn_0"
            android:gravity="center"
            android:singleLine="true"
            android:text="退訂"
            android:textColor="@android:color/white"
            android:textSize="@dimen/font_middle" />
        <TextView
            android:id="@+id/btn_3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:drawableTop="@drawable/bg_btn_0"
            android:gravity="center"
            android:singleLine="true"
            android:text="進(jìn)場"
            android:textColor="@android:color/white"
            android:textSize="@dimen/font_middle" />
    </LinearLayout>

</LinearLayout>

  



如果你嫌上面的做法麻煩:
還有簡單的,使用ActionSlideExpandableListView控件,無需指定具體的把手ID和面板ID;
但是我通常不這樣做,因?yàn)楫吘故褂玫氖茿ctionSlideExpandableListView,而不是普通的ListView,擴(kuò)展性可能會(huì)受限制。
附件使用的是ActionSlideExpandableListView控件
    
public class MainActivity extends Activity {

	@Override
	public void onCreate(Bundle savedData) {

		super.onCreate(savedData);
		// set the content view for this activity, check the content view xml file
		// to see how it refers to the ActionSlideExpandableListView view.
		this.setContentView(R.layout.single_expandable_list);
		// get a reference to the listview, needed in order
		// to call setItemActionListener on it
		ActionSlideExpandableListView list = (ActionSlideExpandableListView)this.findViewById(R.id.list);

		// fill the list with data
		list.setAdapter(buildDummyData());

		// listen for events in the two buttons for every list item.
		// the 'position' var will tell which list item is clicked
		list.setItemActionListener(new ActionSlideExpandableListView.OnActionClickListener() {

			@Override
			public void onClick(View listView, View buttonview, int position) {

				/**
				 * Normally you would put a switch
				 * statement here, and depending on
				 * view.getId() you would perform a
				 * different action.
				 */
				String actionName = "";
				if(buttonview.getId()==R.id.buttonA) {
					actionName = "buttonA";
				} else {
					actionName = "ButtonB";
				}
				/**
				 * For testing sake we just show a toast
				 */
				Toast.makeText(
						MainActivity.this,
					"Clicked Action: "+actionName+" in list item "+position,
					Toast.LENGTH_SHORT
				).show();
			}

		// note that we also add 1 or more ids to the setItemActionListener
		// this is needed in order for the listview to discover the buttons
		}, R.id.buttonA, R.id.buttonB);
	}

	/**
	 * Builds dummy data for the test.
	 * In a real app this would be an adapter
	 * for your data. For example a CursorAdapter
	 */
	public ListAdapter buildDummyData() {
		final int SIZE = 40;
		String[] values = new String[SIZE];
		for(int i=0;i<SIZE;i++) {
			values[i] = "Item "+i;
		}
		return new ArrayAdapter<String>(
				this,
				R.layout.expandable_list_item,
				R.id.text,
				values
		);
	}

  

SlideExpandableListView滑動(dòng)顯示隱藏面板


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會(huì)非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 久一在线视频 | 97中文| 亚洲第一在线播放 | 日日操夜夜操视频 | 精品成人免费一区二区在线播放 | 精品黑人一区二区三区 | 亚洲高清久久 | 狠狠影院 | 欧美日韩精品一区二区三区 | 久久av二区 | 精品在线视频播放 | 天天操天天透 | 天天影视综合网 | 国产一级毛片高清视频 | 九九久久看少妇高潮A片特黄 | 一级毛片视频免费 | 亚洲成a人片在线观看www流畅 | 婷婷色综合久久五月亚洲 | 亚洲国产精品久久 | 一区二区中文字幕 | 成人网页 | 高清久久| 精品一区二区三区不卡 | 骚av在线 | 狠狠操电影 | 色免费视频 | 一区二区三区四区不卡视频 | 污污成人一区二区三区四区 | 91在线观看网站 | 国产精品资源在线观看网站 | 欧美日韩在线视频观看 | 国产欧美日韩亚洲精品区2345 | 草草国产成人免费视频 | 久久夜色精品国产亚洲噜噜 | 天天人人 | 久久精品小视频 | 成人av在线播放 | 久久男人 | 国产综合精品久久亚洲 | 欧美卡一卡二卡新区网站 | 高清国语自产拍免费视频国产 |