Android 搜索像facebook这样的朋友

Android 搜索像facebook这样的朋友,android,Android,如何在android中动态创建这样的搜索好友?非常感谢您的帮助。我使用过autocompletetextview,搜索时它会复制条目,请在此询问:。提前感谢。尝试以下简单代码:(不使用autocompletetextview) XML: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"

如何在android中动态创建这样的搜索好友?非常感谢您的帮助。我使用过autocompletetextview,搜索时它会复制条目,请在此询问:。提前感谢。

尝试以下简单代码:(不使用autocompletetextview

XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".SOF_AutoList" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Name" >

            <requestFocus />
        </EditText>
    </LinearLayout>

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>

</LinearLayout>
public class SOF_AutoList extends Activity
{
    private ListView listview;
    private EditText edttxt;
    private ArrayAdapter<String> adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sof__auto_list);

        ArrayList<String> data = new ArrayList<String>();
        for(int i=0;i<10;i++)
        {
            if(i==0 || i==1 || i==3)
            {
                data.add("Apple "+(i+1));
            }
            else if(i==4 || i==5)
            {
                data.add("Banana "+(i+1));
            }
            else
            {
                data.add("CArrot "+(i+1));
            }
        }

        listview = (ListView)findViewById(R.id.listView1);
        adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1,data);
        listview.setAdapter(adapter);

        edttxt = (EditText)findViewById(R.id.editText1);
        edttxt.addTextChangedListener(new TextWatcher()
        {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // TODO Auto-generated method stub
                adapter.getFilter().filter(s);
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count,
                    int after) {
                // TODO Auto-generated method stub

            }

            @Override
            public void afterTextChanged(Editable s) {
                // TODO Auto-generated method stub

            }
        });
    }


}

Java活动类:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".SOF_AutoList" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Name" >

            <requestFocus />
        </EditText>
    </LinearLayout>

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>

</LinearLayout>
public class SOF_AutoList extends Activity
{
    private ListView listview;
    private EditText edttxt;
    private ArrayAdapter<String> adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sof__auto_list);

        ArrayList<String> data = new ArrayList<String>();
        for(int i=0;i<10;i++)
        {
            if(i==0 || i==1 || i==3)
            {
                data.add("Apple "+(i+1));
            }
            else if(i==4 || i==5)
            {
                data.add("Banana "+(i+1));
            }
            else
            {
                data.add("CArrot "+(i+1));
            }
        }

        listview = (ListView)findViewById(R.id.listView1);
        adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1,data);
        listview.setAdapter(adapter);

        edttxt = (EditText)findViewById(R.id.editText1);
        edttxt.addTextChangedListener(new TextWatcher()
        {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // TODO Auto-generated method stub
                adapter.getFilter().filter(s);
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count,
                    int after) {
                // TODO Auto-generated method stub

            }

            @Override
            public void afterTextChanged(Editable s) {
                // TODO Auto-generated method stub

            }
        });
    }


}
公共类软件自动列表扩展活动
{
私有列表视图列表视图;
私有编辑文本;
专用阵列适配器;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u软件\u自动\u列表);
ArrayList数据=新的ArrayList();

对于(int i=0;iHello Sagar.你能调查一下吗,我无法解决这个问题..谢谢,如果你能想出一个解决办法,我将不胜感激.谢谢你的时间.我也不知道如何处理
URL mUrl
你有没有查看我发送的问题链接?你能告诉我如何解决吗?谢谢,我还没有时间.你一定会查看的这是我有时间的时候。