在Android中如何引进GridView的网格线 [英] In android how to bring gridlines in gridview

查看:165
本文介绍了在Android中如何引进GridView的网格线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

搜索出了很多之后,我可以能够找到我的问题的解决方案,如何在Android

After searching out a lot i could able to find the solution of my problem that in Android how

我可以使人们看到的网格线在我的GridView控件....因为它看起来很简单,但我仍然无法解析

can i make gridlines visible in my gridview....as it seems simple but i still couldn't resolve

问题确实表明一些有益的建议,使网格线或边框上可见

the problem do suggest some useful suggestion to make gridlines or borders visible on

GridView控件.....

gridview.....

上的GridView 网格线

其次答案建议对这个问题,但不知道如何创建GridView控件的子类,并覆盖其方法,, ..?
建议的解决方案

followed the answer suggested for this question but don't know how to create subclass of gridview and override its methods,,..?? suggest solution

推荐答案

如果你需要一个简单的解决方案,您可以添加边框在绘制每个网格项自定义视图来绘制。

If you need a simpler solution, you could add the border to be drawn in your custom views drawn for each grid item.

举例code:

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>

这篇关于在Android中如何引进GridView的网格线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆