欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

怎么在android中實(shí)現(xiàn)列表的展開(kāi)和收縮功能-創(chuàng)新互聯(lián)

本篇文章為大家展示了怎么在android中實(shí)現(xiàn)列表的展開(kāi)和收縮功能,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。

創(chuàng)新互聯(lián)網(wǎng)站建設(shè)提供從項(xiàng)目策劃、軟件開(kāi)發(fā),軟件安全維護(hù)、網(wǎng)站優(yōu)化(SEO)、網(wǎng)站分析、效果評(píng)估等整套的建站服務(wù),主營(yíng)業(yè)務(wù)為成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站成都app開(kāi)發(fā)以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專(zhuān)業(yè)、用心的態(tài)度為用戶(hù)提供真誠(chéng)的服務(wù)。創(chuàng)新互聯(lián)深信只要達(dá)到每一位用戶(hù)的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!

ActivityMain .java

package com.android;


import android.app.ExpandableListActivity;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;

public class ActivityMain extends ExpandableListActivity {

 
 private ExpandableListAdapter mAdapter;
 
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  this.setTitle("ExpandableList");
  mAdapter = new MyExpandableListAdapter(this);
  setListAdapter(mAdapter);
  registerForContextMenu(this.getExpandableListView());
 }

 
 //為列表的每一項(xiàng)創(chuàng)建上下文菜單(即長(zhǎng)按后 呼出的菜單)
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v,
 ContextMenuInfo menuInfo) {
 menu.setHeaderTitle("ContexMenu");
 menu.add(0,0,0,"ContextMenu");
 }

 //單擊上下文菜單后的邏輯
 @Override
 public boolean onContextItemSelected(MenuItem item) {
 
 ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo)item.getMenuInfo();
 String title = ((TextView) info.targetView).getText().toString();
 
 int type =ExpandableListView.getPackedPositionType(info.packedPosition);
 if(type == ExpandableListView.PACKED_POSITION_TYPE_CHILD)
 {
 
 int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
 int childPos = ExpandableListView.getPackedPositionChild(info.packedPosition);
 Toast.makeText(this, title+"-Group Index"+groupPos+"Child Index:"+childPos,
  Toast.LENGTH_SHORT).show();
 return true;
 }
 return false;
 }

MyExpandableListAdapter.java

package com.android;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

public class MyExpandableListAdapter extends BaseExpandableListAdapter {

 private Context mContext;
 
 //父列表數(shù)據(jù)
 private String[] groups ={"group1","group2","group3","group4",""};
 
 //子列表數(shù)據(jù)
 private String [][] children ={
 {"child1"},
 {"child1","child2"},
 {"child1","child2","child3"},
 {"child1","child2","child3","child4"},
 };
 
 MyExpandableListAdapter(Context context){
 mContext = context;
 }
 @Override
 public Object getChild(int groupPosition, int childPosition) {
 // TODO Auto-generated method stub
 return children[groupPosition][childPosition];
 }

 @Override
 public long getChildId(int groupPosition, int childPosition) {
 // TODO Auto-generated method stub
 return childPosition;
 }

 //取子列表中的某一項(xiàng)的view
 @Override
 public View getChildView(int groupPosition, int childPosition,
 boolean isLastChild, View convertView, ViewGroup parent) {
 TextView textView = getGenericView();;
 textView.setText(getChild(groupPosition, childPosition).toString());
 return textView;
 }

 @Override
 public int getChildrenCount(int groupPosition) {
 // TODO Auto-generated method stub
 return children[groupPosition].length;
 }

 @Override
 public Object getGroup(int groupPosition) {
 return groups[groupPosition];
 }

 @Override
 public int getGroupCount() {
 // TODO Auto-generated method stub
 return groups.length;
 }

 @Override
 public long getGroupId(int groupPosition) {
 // TODO Auto-generated method stub
 return groupPosition;
 }

 @Override
 public View getGroupView(int groupPosition, boolean isExpanded,
 View convertView, ViewGroup parent) {
 TextView textView = getGenericView();
 textView.setText(getGroup(groupPosition).toString());
 
 return textView;
 }

 @Override
 public boolean hasStableIds() {
 // TODO Auto-generated method stub
 return true;
 }

 @Override
 public boolean isChildSelectable(int groupPosition, int childPosition) {
 // TODO Auto-generated method stub
 return true;
 }

 //獲取某一項(xiàng)的view的邏輯
 private TextView getGenericView(){
 AbsListView.LayoutParams lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,48);
 TextView textView = new TextView(mContext);
 textView.setLayoutParams(lp);
 textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
 textView.setPadding(32, 0, 0, 0);
 return textView;
 }
 
}
Android是什么

Android是一種基于Linux內(nèi)核的自由及開(kāi)放源代碼的操作系統(tǒng),主要使用于移動(dòng)設(shè)備,如智能手機(jī)和平板電腦,由美國(guó)Google公司和開(kāi)放手機(jī)聯(lián)盟領(lǐng)導(dǎo)及開(kāi)發(fā)。

上述內(nèi)容就是怎么在android中實(shí)現(xiàn)列表的展開(kāi)和收縮功能,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

網(wǎng)頁(yè)標(biāo)題:怎么在android中實(shí)現(xiàn)列表的展開(kāi)和收縮功能-創(chuàng)新互聯(lián)
地址分享:http://aaarwkj.com/article16/dpsigg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號(hào)、App設(shè)計(jì)、企業(yè)網(wǎng)站制作網(wǎng)站導(dǎo)航、域名注冊(cè)、關(guān)鍵詞優(yōu)化

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

綿陽(yáng)服務(wù)器托管
久久精品一区二区三区不卡| 亚洲男女尻逼片视频网站| 日本韩国国产三级在线| 最近中文字幕免费手机版| 亚洲av一区二区在线看| 自拍偷拍视频欧美第一页| 亚洲三级黄片在线观看| 亚洲码与欧洲码一二三| 国产精品久久av高潮呻吟| 饥渴少妇高潮特殊按摩| 粉嫩国产av一区二区三区| 国产强烈高潮粗暴对白| 久久久久久狠狠亚洲综合| 欧美黄片一区二区三区三| 久久人人97超碰人人爱一久久精品| 日本久久精品免费网站| 91免费视频精品麻豆| 欧美日韩国产综合下一页| 欧美亚洲国产另类第一页| 国产精品大屁股白浆一区二区| 日韩欧美高清一区二区| av天堂高清在线观看| 欧美一区二区三在线| 91麻豆精品一二三区在线| 中文字幕精品高清中国| 国产一区二区伦理视频| 久久亚洲中文字幕精品熟女一区| 少妇高潮一区二区三区99| 国产精品日韩理论在线| 国产一区二区欧美精品| 亚洲人午夜射精精品日韩| 亚洲日本va午夜中文字幕一区| 欧美一区二区三区蜜桃| 深夜三级福利在线观看| 国产成人精品手机在线观看| 国产精品日产三级在线观看| 欧美黄片网站在线观看| 国产精品久久久99| 色婷婷一区二区三区网站| 国产高清不卡av在线| 少妇人妻精品一区二区三|