ScrollView+LinearLayout 仿Listview 效果
来源:互联网 发布:js时间控件 时分秒 编辑:程序博客网 时间:2024/06/05 11:20
布局代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.wsd.sun.myapplication.MainActivity"> <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ebebeb" android:orientation="vertical" android:scrollbars="none"> <LinearLayout android:id="@+id/get_lottery" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="15dp" android:orientation="vertical" /> </ScrollView></LinearLayout>
代码
public class MainActivity extends AppCompatActivity { private LinearLayout mLayout; private Context context; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); context=this; mLayout= (LinearLayout) findViewById(R.id.get_lottery); initLottery(); } private void initLottery() { mLayout.removeAllViews(); final String[] tags = new String[]{"去测试0","去测试1","去测试2","去测试3","去测试4","去测试5","去测试6"}; if (tags != null && tags.length > 0) { mLayout.setVisibility(View.VISIBLE); for ( int i = 0; i < tags.length ; i++) { final String name_str = tags[i]; View view = LayoutInflater.from(context).inflate(R.layout.list_item_select_lottery, null); TextView nameView = (TextView) view.findViewById(R.id.list_item_lottery); LinearLayout layoutView = (LinearLayout) view.findViewById(R.id.list_item_layout); nameView.setText(name_str); nameView.setTextColor(0xff4d4d4d); layoutView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(context,"点击了:"+name_str,Toast.LENGTH_SHORT).show(); } }); mLayout.addView(view); } } else { mLayout.setVisibility(View.GONE); } }}demo地址:http://download.csdn.net/detail/wang1897b7/9714057
0 0
- ScrollView+LinearLayout 仿Listview 效果
- 使用LinearLayout,ScrollView自定义ListView,
- 将ListView 改成ScrollView +LinearLayout
- Android LinearLayout+ScrollView 模仿ListView效果,是为了使每个Item的EditText无法失去焦点
- scrollview嵌套listview效果
- 仿ios回弹效果scrollview
- 使用LinearLayout实现ListView,解决ListView和ScrollView滚动冲突
- listview imageview scrollview自定义效果
- ListView适应ScrollView的效果
- ListView 实现类似listview + scrollview滚动效果
- android仿通讯录ListView效果
- android仿通讯录ListView效果
- android仿通讯录ListView效果
- android仿通讯录ListView效果
- android仿通讯录ListView效果
- android仿通讯录ListView效果
- 仿ios listview反弹效果
- ScrollView嵌套LinearLayout又嵌套ListView的布局样式
- java枚举类型
- Spark系列修炼---入门笔记24
- hadoop配置文件hdfs-site.xml
- 计算字符串的宽度与高度
- xilinx开发时遇到的烧写与下载可执行文件出现的效果不一致的解决办法
- ScrollView+LinearLayout 仿Listview 效果
- mysql常用指令
- caffe 编译中出现的错误——fatal error: hdf5.h: 没有那个文件或目录
- A. Crazy Computer
- 钓鱼问题-DFS全排列+模拟
- Emgu 边缘检测,LineSegment2D[]画直线,CircleF[]画圆
- java工厂模式
- linux下创建php的mysql扩展 (pdo_mysql和mysqli)
- list队列数据覆盖问题