一、

 当开发中需要对一些数据进行显示操作的时候,需要用适配器讲其子控件与特定数据绑定以进行显示操作。

需要使用适配器的控件有 Gallery  Spinner ListView GridvView

使用步骤:

1 .Gallery gl=(Gallery)this.findViewById(R.id.Gallery01);------------Gallery资源

2 . BaseAdapter ba=new BaseAdapter(){};--------------获得适配器类(内部类) 放入图片等资源数据

 3.gl.setAdapter(ba);          把适配器放入Gallery

4. gl.setOnItemClickListener(内部类); 监听器 

二、

若想使字符串能连接起来StringBuilder sb=new StringBuilder();//用StringBuilder动态生成信息  

直接使用tv.setText()会新建字符串

三、

   /*当有自定义布局出现在java文件中时 可以把布局提出,放入xml中
    * 定义:
    * LayoutInflater inflater=LayoutInflater.from(ListViewActivity.this);
    * LinearLayout ll = (
      LinearLayout)(inflater.inflate(R.layout.row, null).findViewById(R.id.LinearLayout_row));外部xml文件  和对应的name
    //初始化ImageView
    ImageView  ii=(ImageView)ll.getChildAt(0);
    ii.setImageDrawable(getResources().getDrawable(drawableIds[arg0]));//设置图片

    
    //初始化TextView
    TextView tv=(TextView)ll.getChildAt(1);
    tv.setText(getResources().getText(msgIds[arg0]));//设置内容     
    * */

 

 

 

 

 

posted on 2013-06-05 15:28  小影~~~  阅读(201)  评论(0编辑  收藏  举报