苹果在Android中搜索复制 [英] Replication of Apple's Search in Android

查看:88
本文介绍了苹果在Android中搜索复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个类似于如下所示的UI的http://appsreviews.com/wp-content/uploads/2010/08/Cures-A-Z-App-for-iPhone.jpg

I want to create a UI similar to as shown here http://appsreviews.com/wp-content/uploads/2010/08/Cures-A-Z-App-for-iPhone.jpg

我开始了试图把两个自定义列表并肩想在这个code

I started out with trying to put two custom lists side by side like in this code

import java.util.ArrayList;
import java.util.List;
import java.util.WeakHashMap;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;



public class Emp extends Activity {

    /** Called when the activity is first created. */

    private String tableName = DBHelper.tableName;

    private SQLiteDatabase newDB;


public static WeakHashMap<String, Empbook> temp = new WeakHashMap<String, Empbook>();

final List<Empbook> listOfEmpbook = new ArrayList<Empbook>();
final List<String> listOfAlphabets = new ArrayList<String>();
TextView txt;
EmpbookAdapter adapter = new EmpbookAdapter(this, listOfEmpbook);

Integer pos;
Integer count=0;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    txt=(TextView)findViewById(R.id.textView1);
    ListView list = (ListView) findViewById(R.id.ListView01);
    ListView alist = (ListView) findViewById(R.id.ListView02);

    list.setClickable(true);
    alist.setClickable(true);
    AlphabetListAdapter alphabetadapter = new AlphabetListAdapter(this,
            listOfAlphabets);
    list.setAdapter(adapter);
            alist.setAdapter(alphabetadapter);

的alphabetadapter为在右侧的画面显示字母的列表。 我的XML如下:

the alphabetadapter is for the list displaying alphabets on the right in the screen. My XML is as follows:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView android:text="TextView" android:id="@+id/textView1"
        android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
    <ListView android:id="@+id/ListView01" android:layout_width="280dp"
        android:orientation="vertical" android:layout_height="wrap_content"></ListView>
    <ListView android:id="@+id/ListView02" android:layout_width="wrap_content"
        android:orientation="vertical" android:paddingLeft="282dp"
        android:layout_height="wrap_content"></ListView>
</LinearLayout>

这真实存在的问题是,(被显示这是早先在上面放的xml所述一个,而另一只不显示)只有一个视图在一个时间

The problem that's occurring is that only one view at a time(the one which is put earlier in the above xml is displayed while the other just doesn't appear).

有人可以把我在正确的方向?

Can someone please push me in the right direction?

编辑:我试图设置列表中设置一个零和设置其他的权重为1,它的工作原理部分现在我可以然而看到这两个列表的列表中的一个是没有得到填充....将更新如果我工作了。

I tried to set the weights of the lists setting one to zero and setting the other to 1,it works partially now i can see both lists however one of the list isn't getting populated....will update if i work it out.

下面贴一个答案(一ListView的下降,但。)检查出来。

Posted an answer below (One listview dropped though.) Check it out.

推荐答案

发现周围的工作现在使用一个TextView和嵌套在一个的FrameLayout这样一个ListView:

Found a work around now use a textview and a listview nested in a framelayout like this:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
    <LinearLayout android:orientation="vertical"
        android:layout_width="fill_parent" android:layout_height="fill_parent">

        <ListView android:id="@+id/ListView01" android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:cacheColorHint="#00000000" />
        <TextView android:id="@android:id/empty"
            android:layout_width="fill_parent" android:layout_height="fill_parent"
            android:text="textview" />

    </LinearLayout>

    <LinearLayout android:orientation="vertical"
        android:background="@android:color/transparent" android:id="@+id/sideIndex"
        android:paddingLeft="280dip"
        android:layout_width="300dip" android:layout_height="fill_parent"
        android:gravity="center_horizontal">
        <TextView android:text="T" android:id="@+id/textView1"
            android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>    
    </LinearLayout>
    </FrameLayout>

更可以在这里找到了 http://dotslasha.in/ WP / 143 /创建浮动-观点功能于Android的。 泰和欢呼声! :)

More can be found out here http://dotslasha.in/wp/143/creating-floating-views-in-android . Ty and Cheers !! :)

这篇关于苹果在Android中搜索复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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