得出两个列表视图之间的箭头 [英] draw arrow between two listview

查看:123
本文介绍了得出两个列表视图之间的箭头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在活动二列表视图之间画出箭头,这个概念图像如下图所示。

i want to draw arrow between two listview in activity ,the concept image As shown below.

每个箭头线左列表视图,右列表视图连接两个相同的项目。

every arrow line connect two same item in left listview and right listview.

在左侧列表视图中的任何项目改变它的位置,箭头线必须指向同一项目
在右边的列表视图。

when the any item in left listview change it's position, the arrow line must point to same item in the right listview.

谁能帮我解决这个问题,或者给我一些方法

推荐答案

您必须使用具有3列表视图主XML如下:

You have to use a main XML having 3 ListViews as following:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:weightSum="1" >

    <ListView
        android:id="@+id/listView1"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="0.43" >
    </ListView>

    <ListView
        android:id="@+id/listView2"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="0.14" >
    </ListView>

    <ListView
        android:id="@+id/listView3"
        android:layout_width="0dp"
        android:layout_height="fill_parent"
        android:layout_weight="0.43" >
    </ListView>

</LinearLayout>

然后,你需要一个行XML只说左,右列表视图的列filluprow_string,如下:

Then you need a Row-XML just say "row_string" for LEFT and RIGHT listviews's row fillup, as following:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="35dp" >
</TextView>

然后你需要一个Image_XML只是说row_image中等列表视图如下:

Then you need a Image_XML just say "row_image" for middle listview as following:

<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/imgv1"
    android:layout_width="wrap_content"
    android:layout_height="35dp"
    android:background="#0000ff" />

然后你需要ImageBean,ImageAdapter类主要活动:

Then you will need ImageBean, ImageAdapter class and Main Activity:

ImageBean.java

public class ImageBean {
    String imgnm;
}

ImageAdapter.java

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;

public class ImagesAdapter extends ArrayAdapter<ImageBean>{
    Context context;
    int resId;
    ImageBean[] imgbns;

    public ImagesAdapter(Context context, int resId, ImageBean[] imgbns) {
        super(context, resId, imgbns);
        this.context = context;
        this.resId = resId;
        this.imgbns = imgbns;
    }

    @Override
    public View getView(final int position, final View convertView, final ViewGroup parent) {
        View row = convertView;
        ImgHolder hldr = null;
        if(row == null)
        {
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            row = inflater.inflate(resId, parent, false);
            hldr = new ImgHolder();
            hldr.img1 = (ImageView) row.findViewById(R.id.imgv1);
            row.setTag(hldr);
        }
        else{
            hldr = (ImgHolder)row.getTag();
        }
        hldr.img1.setImageDrawable(context.getResources().getDrawable((R.drawable.right_arrow)));
        //hldr.rImg1.setImageBitmap(readImage(imgbns[position].imgnm));
        return row;
    }

    static class ImgHolder
    {
        ImageView img1;
    }
}

YourMainActivity.java:

进口android.app.Activity;
进口android.os.Bundle;
进口android.widget.ArrayAdapter;
进口android.widget.ListView;

import android.app.Activity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView;

public class HomePage extends Activity {

    ListView lv1, lv2, lv3;
    String[] strs1 = {"11", "11111", "111", "omijnu", "op", "11", "11111", "111", "omijnu", "op", "opiuyj", "abc", "bcd", "asddjjd", "omijnu", "op", "opiuyj"};
    ImageBean[] imgbns;
    //String[] strs3 = {"3333333", "33333", "333333333", "333", "3333", "3333", "333", "3333", "333333333333333333333333", "3333", "333", "333", "333", "3333", "3333333"};

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home);

        lv1 = (ListView) findViewById(R.id.listView1);
        lv2 = (ListView) findViewById(R.id.listView2);
        lv3 = (ListView) findViewById(R.id.listView3);

        imgbns = new ImageBean[25];

        ImagesAdapter imgadptr = new ImagesAdapter(this, R.layout.row_image, imgbns);

        lv1.setAdapter(new ArrayAdapter<String>(this, R.layout.row_string, strs1));
        lv2.setAdapter(imgadptr);
        lv3.setAdapter(new ArrayAdapter<String>(this, R.layout.row_string, strs1));
    }
}

这篇关于得出两个列表视图之间的箭头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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