【发布时间】:2017-07-05 02:56:14
【问题描述】:
我正在显示带有虚拟数据的课程列表。我正在使用自定义 布局以显示课程。从服务器获取对象列表。 在调试模式或运行应用程序时一切正常 在设备上。
现在当我为生产模式构建签名 APK 列表中的数据 没有出现。数据来自服务器,也是 成功映射到列表中。但它没有显示出来。
这是我的自定义布局文件的代码。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvCourseName"
android:gravity="center"
android:textSize="22sp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:textColor="@color/main"
android:background="@drawable/background_course_name"
android:text="@string/english"/>
</RelativeLayout>
这是适配器的代码。
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(getContext());
View view = inflater.inflate(R.layout.course_row_layout,parent,false);
response = getItem(position);
tvCourseName = (TextView)view.findViewById(R.id.tvCourseName);
tvCourseName.setText(response.getTitle());
return view;
}
【问题讨论】:
-
也发布您的 logcat 和 gradle 文件以及颜色文件
-
编辑您的问题并提供所需文件
-
忘掉 getColor() 方法吧。我已经在布局文件中设置了它。我只是忘记在粘贴时评论它..这与颜色无关。运行或调试应用程序时一切正常。
-
发布您的服务器数据,即您用于列表视图的数据
标签: android listview android-custom-view