(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條評論
主站蜘蛛池模板: 午夜天堂精品久久久久 | 亚洲无线视频 | wwwxx免费 | 国产伦精品一区二区三区精品视频 | 国产大片免费观看中文字幕 | 6080yy免费毛片一级新视觉 | 国产网站在线播放 | 59pao成国产成视频永久免费 | 好叼操 | 激情丁香开心久久综合 | 国产在线看片 | 国产精品资源网站在线观看 | 精品亚洲一区二区三区 | 亚洲精品一区二区三区蜜桃久 | 一区二区欧美视频 | 91麻豆国产极品在线观看洋子 | 黄色一级大片在线免费看产 | 亚洲国产午夜精品乱码 | 日韩精品 电影一区 亚洲 | 色欲AV蜜臀AV在线观看麻豆 | 高潮岳喷我一脸 | 精品九九| 亚洲高清在线看 | av免费在线观看av | 黄页成人免费网站 | 亚洲第一色视频 | 成人午夜精品一区二区三区 | 99pao成人国产永久免费视频 | 久久国内精品 | 亚洲精品久久久中文字幕 | 亚洲一一在线 | 欧美精品人爱a欧美精品 | 欧美综合视频 | 韩国一大片a毛片 | 欧美啪啪网址 | 黄网站在线播放 | 免费人成又黄又爽的视频强 | 手机看片国产免费现在观看 | 午夜亚洲福利 | 国产精品一区视频 | 婷婷狠狠干 |