use*_*622 3 android listview background
所以我对listview有一个相当讨厌的问题.我的应用程序工作得很好,直到我的Droid 2上的Android 2.3.3更新.(似乎在三星Evo上工作正常)
这个问题有几个方面.1.空插槽中的背景始终为灰色.2.列表中的最后一个条目在被选中之前似乎是不可见的.选中后,您可以看到黑色文本,但没有背景.3.列表中的其他/旧条目显示正确的背景颜色.
我已经尝试了很多东西,似乎没有什么能解决这个问题.思考?
Listview定义
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:gravity="left|center"
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
android:paddingLeft="1px">
<TextView android:text=""
android:id="@+id/list_view_text_view"
android:layout_width="wrap_content"
android:textSize="13sp"
android:singleLine="false"
android:layout_height="wrap_content"
android:layout_marginLeft="1sp">
</TextView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
listview的主要布局
<ListView android:id="@+id/ListView01"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignRight="@+id/Button06"
android:layout_below="@+id/TextView01"
android:layout_alignLeft="@+id/TextView01"
android:layout_marginBottom="2sp"
android:layout_marginRight="2sp"
android:layout_marginLeft="2sp"
android:layout_above="@+id/EditText01"
android:transcriptMode="normal"
android:footerDividersEnabled="false"
android:headerDividersEnabled="false"
android:gravity="bottom"
>
</ListView>
Run Code Online (Sandbox Code Playgroud)
Listveiw适配器
private class EfficientAdapter extends BaseAdapter {
private LayoutInflater mInflater;
public EfficientAdapter(Context context) {
mInflater = LayoutInflater.from(context);
}
public int getCount() {
return comment_list.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.listview, null);
holder = new ViewHolder();
holder.text = (TextView) convertView
.findViewById(R.id.list_view_text_view);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.text.setText(comment_list.get(position).toString());
return convertView;
}
class ViewHolder {
TextView text;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我用来尝试在主程序中设置背景的代码.
list_view_comments.setBackgroundResource(R.color.color_con);
list_view_comments.setDrawingCacheBackgroundColor(R.color.color_con);
list_view_comments.setBackgroundColor(R.color.color_con);
list_view_comments.setCacheColorHint(R.color.color_con);
Run Code Online (Sandbox Code Playgroud)
rf4*_*f43 12
您的问题与SO上的此问题相同...列表 视图背景在Droid 3上是灰色的
以下是摩托罗拉为解决方案提供的解决方案...... http://community.developer.motorola.com/t5/MOTODEV-Blog/Why-Does-My-ListView-Look-Different/ba-p/17462
基本上他们(摩托罗拉)正在使用自定义主题,你必须使用像
android:overScrollFooter="@null"
Run Code Online (Sandbox Code Playgroud)
编辑 - 上面的链接由于某种原因不再有效.但是,正如凯文在评论中所说,解决方案仍然有效.
| 归档时间: |
|
| 查看次数: |
3269 次 |
| 最近记录: |