English 中文(简体)
• 如何用横向和纵向的滚动来塑造2维图像?
原标题:How to make a 2-dimension image gallery with both horizontal and vertical scrolling?

I m new to Anders and I 我想在每一栏都属于类别的情况下制作成像画,用户可以垂直和横向地进行播种。

我发现了一个有用的职位,说明如何展示图像清单:here。 我不禁要问,能否在安乐见的心目中打上图像清单?

问题回答

在GridView中添加一栏和一栏,以补充家长的观点(或为此而做的事情)。 在LyoutParams,将一席之地放置在GredView上,将其高位推到你想要占据的台阶/座的高度。 那么,你们都需要做的是,当有人把一席之地移到电网的所有其他人。 我将《守则》张贴如下。 注:我对这一概念进行了测试,我刚刚在我的电话上尝试。 然而,这并不是偶然的。 在我继续工作时,我可以更新该守则,使其看不见。

~Aedon :

public class Test extends Activity {
    /** Called when the activity is first created. */
    GridView gv;
    Gallery g[] = new Gallery[3];

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        gv = (GridView) findViewById(R.id.gridview);
        gv.setAdapter(new GAdapter());
        for (int i = 0; i < g.length; i++) {
            g[i] = new Gallery(this);
            g[i].setAdapter(new GGAdapter());
            g[i].setOnTouchListener(new OnTouchListener() {
                @Override
                public boolean onTouch(View arg0, MotionEvent ev) {
                    if (ev.getAction() == MotionEvent.ACTION_UP) {
                        for (int j = 0; j < g.length; j++) {
                            g[j].setSelection(((AdapterView) arg0)
                                    .getSelectedItemPosition());
                        }
                    }
                    return false;
                }
            });
        }
    }

    private class GAdapter extends BaseAdapter {
        public GAdapter() {
        }

        @Override
        public int getCount() {
            return g.length;
        }

        @Override
        public Object getItem(int pos) {
            return pos;
        }

        @Override
        public long getItemId(int pos) {
            return pos;
        }

        @Override
        public View getView(final int pos, View convertView, ViewGroup parent) {

            g[pos].setLayoutParams(new GridView.LayoutParams(gv.getWidth(), gv
                    .getHeight()));
            return g[pos];
        }
    }

    private class GGAdapter extends BaseAdapter {
        int[] images = new int[] { R.drawable.icon, R.drawable.icon,
                R.drawable.icon };

        public GGAdapter() {
        }

        @Override
        public int getCount() {
            return images.length;
        }

        @Override
        public Object getItem(int pos) {
            return pos;
        }

        @Override
        public long getItemId(int pos) {
            return pos;
        }

        @Override
        public View getView(final int pos, View convertView, ViewGroup parent) {
            ImageView mIV = new ImageView(Test.this);
            mIV.setBackgroundResource(images[pos]);
            mIV.setLayoutParams(new Gallery.LayoutParams(gv.getWidth(), gv
                    .getHeight() / 3));
            return mIV;
        }
    }
}

和我的Xml档案:

<?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="vertical" >

    <GridView
        android:id="@+id/gridview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center"
        android:horizontalSpacing="10dp"
        android:numColumns="1"
        android:verticalSpacing="10dp" />

</LinearLayout>




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签