您现在的位置是:主页 > news > 个人名义做网站/营销推广手段有什么

个人名义做网站/营销推广手段有什么

admin2025/6/25 10:14:59news

简介个人名义做网站,营销推广手段有什么,wordpress 站点迁移,上海疫情分布区域本讲内容:ExpandableListView,ExpandableListActivity 可扩展列表 二级列表 手风琴效果accordion本讲源代码下载:Lesson43_ExpandableListView1.zip (42.54 KB, 下载次数: 92)ExpandableListView的效果很实用,配置时有那么一点啰嗦&#xff0…

个人名义做网站,营销推广手段有什么,wordpress 站点迁移,上海疫情分布区域本讲内容:ExpandableListView,ExpandableListActivity 可扩展列表 二级列表 手风琴效果accordion本讲源代码下载:Lesson43_ExpandableListView1.zip (42.54 KB, 下载次数: 92)ExpandableListView的效果很实用,配置时有那么一点啰嗦&#xff0…
本讲内容:ExpandableListView,ExpandableListActivity 可扩展列表 二级列表 手风琴效果accordion
本讲源代码下载:  Lesson43_ExpandableListView1.zip (42.54 KB, 下载次数: 92)
ExpandableListView的效果很实用,配置时有那么一点啰嗦,也容易出错,我在这里例子里会尽量去掉所有干扰信息,好让大家使用时容易借鉴。好我们先看一下运行效果:
1.png
点击一级列表,展开下一级:
2.png
点击二层列表(嵌套的列表)的某一项:
3.png
下面我们来看代码:
1、新建一个项目 Lesson43_ExpandableListView
2、main.xml 的内容如下:
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <linearlayout android:layout_height="fill_parent" android:layout_width="fill_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
  3.         <expandablelistview android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@id/android:list">
  4.         </expandablelistview>
  5. </linearlayout>
复制代码
请注意ExpandableListView标签中id的写法是固定的@id/android:list,因为我们这里用的是ExpandableListActivity,而ExpandableListActivity代码里写死了要寻找的UI元素是它,这和我们以前讲的很多特殊的Activity是一样的,这里再稍作提醒。3、MainActivity.java的代码如下,解释在注释里:
  1. package basic.android.lesson43;
  2. import java.util.ArrayList;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import android.app.ExpandableListActivity;
  7. import android.os.Bundle;
  8. import android.view.View;
  9. import android.widget.ExpandableListView;
  10. import android.widget.SimpleExpandableListAdapter;
  11. import android.widget.Toast;
  12. public class MainActivity extends ExpandableListActivity {
  13.         @Override
  14.         public void onCreate(Bundle savedInstanceState) {
  15.                 super.onCreate(savedInstanceState);
  16.                 setContentView(R.layout.main);
  17.                 // 准备顶层列表数据
  18.                 List
  19. <map string=""><string ,="">> topList = new ArrayList</string></map>
  20. <map string=""><string ,="">>();
  21.                 Map</string><string string="" ,=""> topMap1 = new HashMap</string><string string="" ,="">();
  22.                 Map</string><string string="" ,=""> topMap2 = new HashMap</string><string string="" ,="">();
  23.                 topMap1.put("month", "三月测评项");
  24.                 topMap2.put("month", "四月测评项");
  25.                 topList.add(topMap1);
  26.                 topList.add(topMap2);
  27.                 // 准备二层列表数据
  28.                 List
  29. <list string="">
  30. <map><string ,="">>> nestList = new ArrayList</string></map>
  31. </list>
  32. <list string="">
  33. <map><string ,="">>>();
  34.                 // 准备二层列表第一个子列表数据
  35.                 List
  36. <map string=""><string ,="">> nestList1 = new ArrayList</string></map>
  37. <map string=""><string ,="">>();
  38.                 Map</string><string string="" ,=""> nestMap1 = new HashMap</string><string string="" ,="">();
  39.                 Map</string><string string="" ,=""> nestMap2 = new HashMap</string><string string="" ,="">();
  40.                 Map</string><string string="" ,=""> nestMap3 = new HashMap</string><string string="" ,="">();
  41.                 nestMap1.put("test", "看手");
  42.                 nestMap2.put("test", "吃手");
  43.                 nestMap3.put("test", "玩手");
  44.                 nestList1.add(nestMap1);
  45.                 nestList1.add(nestMap2);
  46.                 nestList1.add(nestMap3);
  47.                 // 准备二层列表第二个子列表数据
  48.                 List
  49. <map string=""><string ,="">> nestList2 = new ArrayList</string></map>
  50. <map string=""><string ,="">>();
  51.                 Map</string><string string="" ,=""> nestMap4 = new HashMap</string><string string="" ,="">();
  52.                 Map</string><string string="" ,=""> nestMap5 = new HashMap</string><string string="" ,="">();
  53.                 nestMap4.put("test", "翻身");
  54.                 nestMap5.put("test", "辨别声音来源方位");
  55.                 nestList2.add(nestMap4);
  56.                 nestList2.add(nestMap5);
  57.                 // 把子列表数据放入
  58.                 nestList.add(nestList1);
  59.                 nestList.add(nestList2);
  60.                 // 准备数据匹配器
  61.                 SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter(
  62.                                 this, //1.上下文
  63.                                 topList, //2.顶层数据列表
  64.                                 android.R.layout.simple_expandable_list_item_1, // 3.一层显示样式
  65.                                 new String[]{"month"}, //4.顶层map的键
  66.                                 new int[]{android.R.id.text1}, // 5.顶层数据显示的View ID
  67.                                 nestList, //6.二层数据列表
  68.                                 android.R.layout.simple_list_item_1, //7.二层显示样式
  69.                                 new String[]{"test"}, //8.二层map的键
  70.                                 new int[]{android.R.id.text1} //9.二层数据显示的View ID
  71.                                 );
  72.                 //设置数据匹配器
  73.                 this.setListAdapter(adapter);
  74.         }
  75.         @Override
  76.         public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
  77.                 Toast.makeText(this, "嵌套列表被点击,顶层列表定位"+groupPosition+"二层列表定位"+childPosition, Toast.LENGTH_LONG).show();
  78.                 return super.onChildClick(parent, v, groupPosition, childPosition, id);
  79.         }
  80.         @Override
  81.         public void onGroupCollapse(int groupPosition) {
  82.                 Toast.makeText(this, "顶层列表收缩,列表定位"+groupPosition, Toast.LENGTH_LONG).show();
  83.                 super.onGroupCollapse(groupPosition);
  84.         }
  85.         @Override
  86.         public void onGroupExpand(int groupPosition) {
  87.                 Toast.makeText(this, "顶层列表展开,列表定位"+groupPosition, Toast.LENGTH_LONG).show();
  88.                 super.onGroupExpand(groupPosition);
  89.         }
  90. }
  91. </string></map>
  92. </string></map>
  93. </string></map>
  94. </list></string></map>
复制代码

4、编译并运行程序即可看到上面的效果。那么本节课就到这里了,Android中很多内容就像本节的ExpandableListView一样讨厌,来,我们一起鄙视一下^_^
转自:http://www.apkbus.com/android-1129-1-1.html

转载于:https://www.cnblogs.com/jyan/articles/2536933.html