扣丁学堂——布局性能优化(Hierarchy Viewer工具)
2016-01-29 10:16
369 查看
一丶课程讲解
本节主要源码
xml
MainActivity·
本节主要源码
xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:background="@android:color/holo_blue_dark"> <ViewStub android:layout_width="match_parent" android:layout_height="wrap_content" android:layout="@layout/inc" android:inflatedId="@+id/stub_import" android:id="@+id/stub_import" /> <include layout="@layout/title_bar"/> </LinearLayout> <ListView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/listView" /> </LinearLayout>
MainActivity·
public class MainActivity extends AppCompatActivity implements View.OnClickListener{ private ImageView iv; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); iv = (ImageView) findViewById(R.id.imageView); iv.setOnClickListener(this); ListView lv = (ListView) findViewById(R.id.listView); ArrayList<HashMap<String,String>> list = new ArrayList<>(); for (int i=1;i<20;i++){ HashMap<String,String> map = new HashMap<>(); map.put("title","title-"+i); map.put("content","content-"+i); list.add(map); } SimpleAdapter simpleAdapter = new SimpleAdapter(this,list,R.layout.item_layout2,new String[]{"title","content"},new int[]{R.id.textView_title,R.id.textView2_content}); lv.setAdapter(simpleAdapter); } @Override public void onClick(View v) { if (v.getId()==R.id.imageView){ ViewStub vs =(ViewStub)findViewById(R.id.stub_import); vs.setVisibility(View.VISIBLE); // // View v = vs.inflate(); } } }
相关文章推荐
- 操作系统学习基本概念汇总
- java模拟实现生产者---消费者问题
- 大道至简——书摘与思考[二]
- JAVA的BIT数组
- web移动端常见问题解决方案
- PLSQL快捷键设置
- [Shader 着色器] 学习前了解知识
- 基于遗传算法的寻路模拟
- iOS 动画之购物车 贝塞尔曲线
- Linux/Mac 常用命令
- 让iOS程序可以和 iTunes 进行文件交互
- 编译原理学习基本概念汇总
- Android项目中引用本地aar文件的方法
- 10. redis 高级:事务&&发布订阅
- 11. redis 高级:安全&&主从复制
- SLAM 学习
- DTD和Schema
- R语言矩阵运算加速
- 资源回收导致重建 Activity和 Fragment
- Unity WebPlayer自定义进度条界面