在搜索了很多之后,我能够找到我的问题的解决方案,在 Android 中如何
我可以让网格线在我的网格视图中可见吗......因为它看起来很简单,但我仍然无法解决
该问题确实提出了一些有用的建议,以使网格线或边框在
网格视图.....
遵循为这个问题建议的答案,但不知道如何创建 gridview 的子类并覆盖其方法,,..?? 提出解决方案
在搜索了很多之后,我能够找到我的问题的解决方案,在 Android 中如何
我可以让网格线在我的网格视图中可见吗......因为它看起来很简单,但我仍然无法解决
该问题确实提出了一些有用的建议,以使网格线或边框在
网格视图.....
遵循为这个问题建议的答案,但不知道如何创建 gridview 的子类并覆盖其方法,,..?? 提出解决方案
如果您需要更简单的解决方案,您可以在为每个网格项目绘制的自定义视图中添加要绘制的边框。
示例代码:
public class ExampleAdapter extends BaseAdapter {
private Activity activity;
private LayoutInflater inflater;
public ExampleAdapter(Activity activity)
{
this.activity = activity;
this.inflater = activity.getLayoutInflater();
}
@Override
public View getView(int pos, View convertView, ViewgGroup parent) {
ViewHolder holder = null;
if(converView == null) {
convertView = inflater.inflate(R.layout.view_example);
holder = new ViewHolder();
//Set holder ids here
holder.title = convertView.findViewById(R.id.title)
}
//Populate your holder here with data here.
holder.title.setText("My Awesome Title!");
convertView.setTag(holder);
return convertView;
}
}
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/grid_item_width"
android:layout_height="@dimen/grid_item_height"
android:background="@color/grid_border"
android:padding="1dip" >
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" >
<TextView android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</FrameLayout>
</FrameLayout>