Android ListView in how to make the line do not show different colors font

2010-11-11  来源:本站原创  分类:Mobile  人气:146 

ListView every step of the formation is carried out in the Adapter, but if we do not have the line not the same as the font color or background is different, we just modify the adpter the getItemView our code on the line.

Before the usual practice is:

  1. Look convertView is not as null, if null, we will create a new view, its development of the layout file; if not null, we will convertView.getTag () assigned to the view.
  2. Set the view content.

ChildItemView childItemView = null; 

                if (convertView == null) {

                        LayoutInflater mInflater_ = LayoutInflater.from(mContext);
                        //set the place for the child item view
                        convertView = mInflater_.inflate(R.layout.expandablechildrenlayout, null);

                        childItemView = new ChildItemView();
                convertView.findViewById(R.id.expandable_children_text);

                        childItemView.childtitle = (TextView) convertView.findViewById(R.id.expandable_child_title);

                        convertView.setTag(childItemView);
                } else {
                        //get the child item
                        childItemView = (ChildItemView) convertView.getTag();
                }

Our approach now is that no matter convertView is not for null, we need to set according to their own layout files, and then set the view content.

if(itemChild.mRead.equals("0")){

                                LayoutInflater mInflater_ = LayoutInflater.from(mContext);
                                //set the place for the child item view
                                convertView = mInflater_.inflate(R.layout.expandablechildrenlayout, null);
                                childItemView = new ChildItemView();
                                childItemView.childtitle = (TextView) convertView.findViewById(R.id.expandable_child_title);
                }else{

                        LayoutInflater mInflater_ = LayoutInflater.from(mContext);
                        //set the place for the child item view
                        convertView = mInflater_.inflate(R.layout.expandablechildrenlayoutbold, null);
                        childItemView = new ChildItemView();
                        childItemView.childtitle = (TextView) convertView.findViewById(R.id.expandable_child_title);
                }

Finally, setting:

childItemView.childtitle.setText(inforText.toString());
相关文章
  • Android ListView in how to make the line do not show different colors font 2010-11-11

    ListView every step of the formation is carried out in the Adapter, but if we do not have the line not the same as the font color or background is different, we just modify the adpter the getItemView our code on the line. Before the usual practice is

  • 2010.12.13 --- android listView rolling load display 2010-12-14

    2010.12.13 --- android listView rolling load display Because the data should be larger than the display 20 and then scroll to the bottom of the display 20 when the load in order to go down listView.setOnScrollListener(new OnScrollListener(){ public v

  • Android ListView to display in the pictures and text 2011-05-20

    ListView in the format of a line <? Xml version = "1.0" encoding = "utf-8"?> <LinearLayout xmlns: Android = " http://schemas.android.com/apk/res/android " android: layout_width = "match_parent" android: lay

  • Android ListView xml configuration 2011-05-31

    1 <ListView android:id= "@+id/locallist_lv" android:layout_width= "fill_parent" 2 android:layout_height= "fill_parent" android:layout_above= "@id/btm_menu" 3 android:layout_below= "@id/top_menu" 4 andro

  • Introduction chapter of Android ListView 2010-02-26

    Introduction to Part VI of Android ListView ListView is a frequently used controls, ListView inside of each sub-item Item can be a string, it can be a combination of controls. First talk about the implementation of ListView: 1. Preparation ListView t

  • Android ListView background into a transparent set method 2010-09-25

    Android ListView background into a transparent set the way, if you just change the background color, you can directly specify android: cacheColorHint you want color, if you are using images to do the background, then it is also simply android: cacheC

  • Android ListView common usage 2010-11-30

    ListView control is more commonly used, but always felt a bit tedious to create ListView steps, so in this summary, for easy access. Program effects is to implement a ListView, ListView which has the title, content and images, and add the click and l

  • 2010.12.15 --- android listView display pictures 2010-12-16

    2010.12.15 --- android listView display pictures Requirements: display images inside the listView Idea: online see some examples listView generally inherited SimpleAdapter, SimpleAdapter but can not directly display images on the network so we only n

  • 2010.12.16 --- android listView display picture memory overflow 2010-12-16

    2010.12.16 --- android listView display picture memory overflow Wrote yesterday listView load, they would have reported a large number of images of memory exception In fact, wrote yesterday there are two problems: 1, memory overflow 2, loading images

  • Introduction to Part VI of Android ListView (a) 2010-12-17

    Is a frequently used ListView control, ListView Item inside the every child can make a string, it can be a combination of control. First talk about the implementation of ListView: 1. For ListView to display data; 2. Using one-dimensional or multidime

  • 2010.12.29 --- android listview ExpandableList scalable 2011-01-04

    2010.12.29 --- android listview ExpandableList scalable Directly on the code, we look at it relatively simple to understand package com.huitu.project; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;

  • Android ListView control to solve the rolling black background 2011-01-10

    If we use the non-black background when the ListView control, Android ListView by default may scroll the list control's background when suddenly become black. This may cause the program to the black background and not the subject of the main program

  • Android ListView长按弹出菜单二种实现方式示例 2014-01-16

    这篇文章主要介绍了Android ListView长按弹出菜单的方法,大家参考实现 /** * 知识点1:ListView item:两种长按弹出菜单方式 * 知识点2:ListView SimpleAdapter的使用 * 知识点 3:在java代码中创建一个ListView */ public class ListOnLongClickActivity extends Activity { private LinearLayout myListViewlayout; private List

  • Android ListView数据绑定显示的三种解决方法 2014-03-28

    本篇文章小编为大家介绍,Android ListView数据绑定显示的三种解决方法.需要的朋友参考下 首先,创建一个用于显示一个item的layout,名为item.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_wi

  • 基于Android ListView之加载使用技巧 2014-05-10

    本篇文章小编为大家介绍,基于Android ListView之加载使用技巧.需要的朋友参考下 程序员很多,遍地都是,高手也很多,但是懂设计的程序员并不多,我觉得我们不仅要成为一个coder还要成为一个designer. 我是一个比较注重ued的人,如果对一个app来说,程序是app的内涵那么设计就是要体现app的外在美观. 曾经看到一篇招聘用户体验设计师的信息问道 如果说,在我们身边,设计师具有表达思想的力量:工程师具有实现思想的力量. 那么请问用户体验设计师具有什么力量,有资格成为团队成员?

  • android listview 水平滚动和垂直滚动的小例子 2014-07-29

    android listview 水平滚动和垂直滚动的小例子,需要的朋友可以参考一下 网上有很多解决 android listview 水平和垂直滚动的代码,我没有按照他们说的做(以前没搜到 O(∩_∩)O~) 我采用的是添加HorizontalScrollView Java代码 < ScrollView android:id="@+id/ScrollView01" android:layout_height="300px" android:layout_x=

  • android ListView和ProgressBar(进度条控件)的使用方法 2014-09-17

    这篇文章主要介绍了android ListView控件的使用方法和ProgressBar(进度条控件)的使用方法,代码大家可以参考使用 ListView控件的使用:ListView控件里面装的是一行一行的数据,一行中可能有多列,选中一行,则该行的几列都被选中,同时可以触发一个事件,这种控件在平时还是用得很多的. 使用ListView时主要是要设置一个适配器,适配器主要是用来放置一些数据.使用起来稍微有些复杂,这里用的是android自带的SimpleAdapter,形式如下: android.w

  • android ListView的右边滚动滑块启用方法 分享 2014-10-19

    android ListView的右边滚动滑块启用方法 分享,需要的朋友可以参考一下 多开发者不知道ListView列表控件的快速滚动滑块是如何启用的,这里Android开发网告诉大家,辅助滚动滑块只需要一行代码就可以搞定,如果你使用XML布局只需要在ListView节点中加入 android:fastScrollEnabled="true" 这个属性即可,而对于Java代码可以通过myListView.setFastScrollEnabled(true); 来控制启用,参数false

  • android ListView 一些重要属性详解 2014-12-26

    android ListView 一些重要属性详解,需要的朋友可以参考一下 首先是stackFromBottom属性,这只该属性之后你做好的列表就会显示你列表的最下面,值为true和false android:stackFromBottom="true" 第二是transciptMode属性,需要用ListView或者其它显示大量Items的控件实时跟踪或者查看信息,并且希望最新的条目可以自动滚动到可视范围内.通过设置的控件transcriptMode属性可以将Android平台的控件

  • Android listview动态添加删除测试 2012-05-03

    最近在学习Android ,listview会经常使用到.做了些测试.有问题请指正.大家一起讨论. ListviewTest.java Activity类 import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Random; import android.app.Activity; import android.os.Bundle; import an