package tjuci.edu.dl;
import android.app.ExpandableListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseExpandableListAdapter;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;
public class Second extends ExpandableListActivity {
//一级分组
String[] arrTypes = {"山东","天津","湖南"};
//二级分组
String[][] arr = {
{"广州","深圳","珠海","中山"}
,{"桂林","柳州","南宁","广西"}
,{"北京","河北","河南","四川"}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
ExpandableListAdapter ela = new BaseExpandableListAdapter() {
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return true;
}
@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
LinearLayout ll = new LinearLayout(Second.this);
ll.setOrientation(0);
TextView tv = getTextView();
tv.setText(getGroup(groupPosition).toString());
ll.addView(tv);
return ll;
}
@Override
public long getGroupId(int groupPosition) {
// TODO Auto-generated method stub
return groupPosition;
}
@Override
public int getGroupCount() {
// TODO Auto-generated method stub
return arrTypes.length;
}
@Override
public Object getGroup(int groupPosition) {
// TODO Auto-generated method stub
return arrTypes[groupPosition];
}
@Override
public int getChildrenCount(int groupPosition) {
// TODO Auto-generated method stub
return arr[groupPosition].length;
}
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
TextView tv = getTextView();
tv.setText(getChild(groupPosition, childPosition).toString());
return tv;
}
@Override
public long getChildId(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return childPosition;
}
@Override
public Object getChild(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return arr[groupPosition][childPosition];
}
public TextView getTextView(){
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 64);
TextView tv = new TextView(Second.this);
tv.setLayoutParams(lp);
tv.setGravity(Gravity.CENTER_VERTICAL|Gravity.LEFT);
tv.setPadding(36, 0, 0, 0);
return tv;
}
};
this.setListAdapter(ela);
getExpandableListView().setOnChildClickListener(new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
// TODO Auto-generated method stub
Intent intent = getIntent();
Bundle bundle = new Bundle();
bundle.putString("city", arr[groupPosition][childPosition]);
intent.putExtras(bundle);
setResult(0, intent);
finish();
return false;
}
});
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Android应用源码之RequestCodeAndResponseCodeSample.zip项目安卓应用源码下载
共30个文件
class:11个
png:6个
xml:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 170 浏览量
2022-03-08
07:06:52
上传
评论
收藏 75KB ZIP 举报
温馨提示
Android应用源码之RequestCodeAndResponseCodeSample.zip项目安卓应用源码下载Android应用源码之RequestCodeAndResponseCodeSample.zip项目安卓应用源码下载 1.适合学生毕业设计研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考
资源推荐
资源详情
资源评论
收起资源包目录
Android应用源码之RequestCodeAndResponseCodeSample.zip (30个子文件)
Android应用源码之RequestCodeAndResponseCodeSample
Android应用源码之RequestCodeAndResponseCodeSample
RequestCodeAndResponseCodeSample
.project 868B
bin
RequestCodeAndResponseCodeSample.apk 16KB
res
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
drawable-mdpi
ic_launcher.png 2KB
resources.ap_ 11KB
classes
tjuci
edu
dl
R$string.class 409B
R$layout.class 376B
Second$2.class 1KB
R$drawable.class 389B
First.class 1KB
First$1.class 951B
R.class 489B
R$attr.class 322B
Second$1.class 3KB
Second.class 1KB
R$id.class 391B
classes.dex 7KB
proguard.cfg 1KB
AndroidManifest.xml 822B
src
tjuci
edu
dl
Second.java 4KB
First.java 1KB
project.properties 361B
res
values
strings.xml 230B
layout
main.xml 605B
drawable-ldpi
ic_launcher.png 2KB
drawable-hdpi
ic_launcher.png 4KB
drawable-mdpi
ic_launcher.png 3KB
.classpath 364B
gen
tjuci
edu
dl
R.java 783B
共 30 条
- 1
资源评论
yxkfw
- 粉丝: 77
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功