Android Listview未在tabview中完全查看

Android Listview未在tabview中完全查看,android,listview,android-linearlayout,android-xml,android-tabactivity,Android,Listview,Android Linearlayout,Android Xml,Android Tabactivity,我试图在选项卡视图中显示列表视图,但列表视图不能完全查看。列表视图也没有滚动。我无法跟踪问题。请查看是否找到问题。任何类型的帮助都将非常有用 这是我的密码: 选项卡式XMl: <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"

我试图在选项卡视图中显示列表视图,但列表视图不能完全查看。列表视图也没有滚动。我无法跟踪问题。请查看是否找到问题。任何类型的帮助都将非常有用

这是我的密码: 选项卡式XMl:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/white" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#ffffffff"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@color/light_gray"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/back_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:gravity="left"
                android:padding="2.0dip"
                 android:layout_gravity="center_vertical"
                android:textColor="@color/blue"
                android:background="@android:color/transparent"
                android:text="Back"
                android:textStyle="bold"
                android:typeface="normal" />

            <TextView
                android:id="@+id/clientusername"
                android:layout_width="match_parent"
                android:layout_height="45.0dip"
                android:layout_gravity="center_horizontal"
                android:gravity="center_horizontal"
                android:padding="2.0dip"
                android:text="UserName Here"
                android:textColor="@color/blue"
                android:textSize="27.0dip"
                android:textStyle="bold"
                android:typeface="monospace" />

        </LinearLayout>

        <TabHost
            android:id="@android:id/tabhost"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginTop="10.0dip" >

            <LinearLayout
                android:id="@+id/tabcontainer"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical" >

                <TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="250.0dip"
                    android:layout_height="40.0dip"
                    android:layout_gravity="center"
                    android:gravity="center" />

                <FrameLayout
                    android:id="@android:id/tabcontent"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_marginTop="15.0dip"
                    android:background="@android:color/white"
                    android:fadeScrollbars="false"
                    android:fadingEdge="none"
                    android:scrollbars="none" />
            </LinearLayout>
        </TabHost>
    </LinearLayout>

</ScrollView>
import android.app.TabActivity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.TextView;
import commonUtilities.VariableClass;

public class ContactsGroup extends TabActivity
{
  private static LayoutInflater inflater;
  private static Intent intent;
  private static final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.5F);
  private static TabHost.TabSpec spec;
  private static TabHost tabHost;
  private String BLUE = "#296fa2";
  private String GRAY = "#929292";
  private String WHITE = "#FFFFFF";

  private TextView label1;
  private TextView label2;
  private View tab;
  TextView user_name;
  Button back_button;

  private void clearTabStyles()
  {
    for (int i = 0; ; i++)
    {
      if (i >= getTabWidget().getChildCount())
        return;
      this.tab = getTabWidget().getChildAt(i);
      this.tab.setBackgroundColor(Color.parseColor("#666666"));
    }
  }

  public void onBackPressed()
  {

    finish();
    super.onBackPressed();
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(R.layout.clients_tab);
    try
    {
      this.user_name = ((TextView)findViewById(R.id.clientusername));
      this.user_name.setTypeface(MainActivity.tp_semi_bold);
      back_button=(Button)findViewById(R.id.back_button);
      try
      {

        this.user_name.setVisibility(View.INVISIBLE);
        inflater = (LayoutInflater)getSystemService("layout_inflater");
        tabHost = getTabHost();
        this.tab = inflater.inflate(R.layout.tab, getTabWidget(), false);
        this.tab.setLayoutParams(params);
        this.label1 = ((TextView)this.tab.findViewById(R.id.tabLabel1));
        this.label1.setTypeface(MainActivity.tp_normal);
        this.label1.setText(VariableClass.Messages.APPCONTACTS);
        intent = new Intent(this, AppContacts.class);

        spec = tabHost.newTabSpec("home").setIndicator(this.tab).setContent(intent);
        tabHost.addTab(spec);
        this.tab = inflater.inflate(R.layout.tab, getTabWidget(), false);
        this.tab.setLayoutParams(params);
        this.label2 = ((TextView)this.tab.findViewById(R.id.tabLabel2));
        this.label2.setTypeface(MainActivity.tp_normal);
        this.label2.setText(VariableClass.Messages.ALLCONTACTS);
        intent = new Intent(this, PhoneContacts.class);

        spec = tabHost.newTabSpec("users").setIndicator(this.tab).setContent(intent);
        tabHost.addTab(spec);
        tabHost.setCurrentTab(0);
        getTabWidget().getChildAt(0).setBackgroundColor(-1);
        this.label1.setTextColor(Color.parseColor(this.WHITE));
        this.label1.setBackgroundResource(R.drawable.bluetab_background);
        this.label2.setTextColor(Color.parseColor(this.GRAY));
        this.label2.setBackgroundResource(R.drawable.whitetab_background);
        tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener()
        {
          public void onTabChanged(String paramAnonymousString)
          {
           clearTabStyles();
            View localView;
            if (paramAnonymousString.equals("home"))
            {
              localView =getTabWidget().getChildAt(0);
             label1.setTextColor(Color.parseColor(WHITE));
             label1.setBackgroundResource(R.drawable.bluetab_background);
             label2.setTextColor(Color.parseColor(GRAY));
             label2.setBackgroundResource(R.drawable.whitetab_background);
            }
            else if( paramAnonymousString.equals("users"))
            {
                localView =getTabWidget().getChildAt(1);
               label1.setTextColor(Color.parseColor(GRAY));
               label1.setBackgroundResource(R.drawable.whitetab_background);
               label2.setTextColor(Color.parseColor(WHITE));
               label2.setBackgroundResource(R.drawable.bluetab_background);
            }
          }
        });
      }
      catch (Exception localException2)
      {

          localException2.printStackTrace();
          finish();

      }
    }
    catch (Exception localException1)
    {
      localException1.printStackTrace();
    }
  }
  @Override
    protected void onResume() {
        // TODO Auto-generated method stub
      back_button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
        }
    });
        super.onResume();
    }
  @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
    }
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/parent_clients_list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffffff"
    android:orientation="vertical" >

    <EditText
        android:id="@+id/con_search_button"
        android:layout_width="fill_parent"
        android:layout_height="40.0dip"
        android:layout_margin="5.0dip"
        android:background="@drawable/edbackground"
        android:drawableLeft="@drawable/search"
        android:drawablePadding="10.0dip"
        android:hint="search clients"
        android:textColor="@color/gray"
        android:textSize="15.0dip" />

    <ListView
        android:id="@+id/con_list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_margin="5.0dip"
        android:layout_weight="0.1"
        android:background="@android:color/white" />

</LinearLayout>
import java.util.ArrayList;
import pjsua2Utilies.AppData;
import commonUtilities.CommonUtility;
import commonUtilities.VariableClass;
import dto.Contacts;
import Adapter.AppContactListAdapter;
import Adapter.ContactListAdapter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.WindowManager.BadTokenException;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class AppContacts extends Activity {
    ListView contactslistview;
    EditText search_bar;
    ArrayList<Contacts>contactslist; 
    AppContactListAdapter adapter;
    Context c ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.contacts_list);
        initialise();
    }
    public void initialise()
    {
        contactslistview = (ListView)findViewById(R.id.con_list);
        search_bar = (EditText)findViewById(R.id.con_search_button);
        c = AppContacts.this;
    }
    @Override
    protected void onStart() {
        // TODO Auto-generated method stub
        new getContacts().execute(null,null,null);
        super.onStart();
    }
    @Override
    protected void onResume() {
        // TODO Auto-generated method stub

        contactslistview.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {

                if(AppData.reg_status){
                    Contacts dto = (Contacts)arg0.getItemAtPosition(arg2);
                    Intent i = new Intent(c, CallingScreen.class);
                    i.putExtra(VariableClass.Vari.NAMETOCALL,dto.getName());
                    i.putExtra(VariableClass.Vari.NUMBERTOCALL,dto.getNumber());
                    dto=null;
                    startActivity(i);
                }

            }
        });
        search_bar.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // TODO Auto-generated method stub
                String startwith=search_bar.getText().toString();
                ArrayList<Contacts>filterList=new ArrayList<Contacts>();
                int contactsCount=contactslist.size();
                for(int i=0;i<contactsCount;i++)
                {
                    if(contactslist.get(i).getName().startsWith(startwith) ||contactslist.get(i).getName().toLowerCase().startsWith(startwith) || contactslist.get(i).getName().toUpperCase().startsWith(startwith))
                    {
                        filterList.add(contactslist.get(i));

                    }
                }
                adapter=new AppContactListAdapter(c, filterList);
                contactslistview.setAdapter(adapter);
            }
            @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
            }
        });
        super.onResume();
    }
    class getContacts extends AsyncTask<Void,Void, Void>{
        String response=null;
        @Override
        protected void onPostExecute(Void result) {

            try {
                if(!((Activity)(c)).isFinishing())

                if(response.equals("1"))
                {

                }
                else if(response.equals("0")){}

                else{
                    if(contactslist==null&&contactslist.size()==0)
                        Toast.makeText(c, "No Contacts Found",2000).show();
                    else{
                        adapter=new AppContactListAdapter(c,contactslist);
                        contactslistview.setAdapter(adapter);
                    }
                }
            } catch (BadTokenException e) {
                // TODO: handle exception
            }
            catch (Exception e) {
                // TODO: handle exception
            }


            super.onPostExecute(result);
        }

        @Override
        protected void onPreExecute() {
            // TODO Auto-generated method stub

            contactslist=new ArrayList<Contacts>();
            try {
                new CommonUtility().show_PDialog(c, "Fetching Contacts..");

            } catch (BadTokenException e) {
                // TODO: handle exception
            }
            catch (Exception e) {
                // TODO: handle exception
            }

            super.onPreExecute();
        }

        @Override
        protected Void doInBackground(Void... params) {
            // TODO Auto-generated method stub
            response=Apis.getApisInstance(c).getContactsList("","");
            if(response.contains("{"))
            {
                contactslist=new JsonParser().getAllPhone91Contacts(response);
            }
            return null;
        }

    }
}
活动1 XML:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/white" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#ffffffff"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@color/light_gray"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/back_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:gravity="left"
                android:padding="2.0dip"
                 android:layout_gravity="center_vertical"
                android:textColor="@color/blue"
                android:background="@android:color/transparent"
                android:text="Back"
                android:textStyle="bold"
                android:typeface="normal" />

            <TextView
                android:id="@+id/clientusername"
                android:layout_width="match_parent"
                android:layout_height="45.0dip"
                android:layout_gravity="center_horizontal"
                android:gravity="center_horizontal"
                android:padding="2.0dip"
                android:text="UserName Here"
                android:textColor="@color/blue"
                android:textSize="27.0dip"
                android:textStyle="bold"
                android:typeface="monospace" />

        </LinearLayout>

        <TabHost
            android:id="@android:id/tabhost"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginTop="10.0dip" >

            <LinearLayout
                android:id="@+id/tabcontainer"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical" >

                <TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="250.0dip"
                    android:layout_height="40.0dip"
                    android:layout_gravity="center"
                    android:gravity="center" />

                <FrameLayout
                    android:id="@android:id/tabcontent"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_marginTop="15.0dip"
                    android:background="@android:color/white"
                    android:fadeScrollbars="false"
                    android:fadingEdge="none"
                    android:scrollbars="none" />
            </LinearLayout>
        </TabHost>
    </LinearLayout>

</ScrollView>
import android.app.TabActivity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.TextView;
import commonUtilities.VariableClass;

public class ContactsGroup extends TabActivity
{
  private static LayoutInflater inflater;
  private static Intent intent;
  private static final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.5F);
  private static TabHost.TabSpec spec;
  private static TabHost tabHost;
  private String BLUE = "#296fa2";
  private String GRAY = "#929292";
  private String WHITE = "#FFFFFF";

  private TextView label1;
  private TextView label2;
  private View tab;
  TextView user_name;
  Button back_button;

  private void clearTabStyles()
  {
    for (int i = 0; ; i++)
    {
      if (i >= getTabWidget().getChildCount())
        return;
      this.tab = getTabWidget().getChildAt(i);
      this.tab.setBackgroundColor(Color.parseColor("#666666"));
    }
  }

  public void onBackPressed()
  {

    finish();
    super.onBackPressed();
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(R.layout.clients_tab);
    try
    {
      this.user_name = ((TextView)findViewById(R.id.clientusername));
      this.user_name.setTypeface(MainActivity.tp_semi_bold);
      back_button=(Button)findViewById(R.id.back_button);
      try
      {

        this.user_name.setVisibility(View.INVISIBLE);
        inflater = (LayoutInflater)getSystemService("layout_inflater");
        tabHost = getTabHost();
        this.tab = inflater.inflate(R.layout.tab, getTabWidget(), false);
        this.tab.setLayoutParams(params);
        this.label1 = ((TextView)this.tab.findViewById(R.id.tabLabel1));
        this.label1.setTypeface(MainActivity.tp_normal);
        this.label1.setText(VariableClass.Messages.APPCONTACTS);
        intent = new Intent(this, AppContacts.class);

        spec = tabHost.newTabSpec("home").setIndicator(this.tab).setContent(intent);
        tabHost.addTab(spec);
        this.tab = inflater.inflate(R.layout.tab, getTabWidget(), false);
        this.tab.setLayoutParams(params);
        this.label2 = ((TextView)this.tab.findViewById(R.id.tabLabel2));
        this.label2.setTypeface(MainActivity.tp_normal);
        this.label2.setText(VariableClass.Messages.ALLCONTACTS);
        intent = new Intent(this, PhoneContacts.class);

        spec = tabHost.newTabSpec("users").setIndicator(this.tab).setContent(intent);
        tabHost.addTab(spec);
        tabHost.setCurrentTab(0);
        getTabWidget().getChildAt(0).setBackgroundColor(-1);
        this.label1.setTextColor(Color.parseColor(this.WHITE));
        this.label1.setBackgroundResource(R.drawable.bluetab_background);
        this.label2.setTextColor(Color.parseColor(this.GRAY));
        this.label2.setBackgroundResource(R.drawable.whitetab_background);
        tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener()
        {
          public void onTabChanged(String paramAnonymousString)
          {
           clearTabStyles();
            View localView;
            if (paramAnonymousString.equals("home"))
            {
              localView =getTabWidget().getChildAt(0);
             label1.setTextColor(Color.parseColor(WHITE));
             label1.setBackgroundResource(R.drawable.bluetab_background);
             label2.setTextColor(Color.parseColor(GRAY));
             label2.setBackgroundResource(R.drawable.whitetab_background);
            }
            else if( paramAnonymousString.equals("users"))
            {
                localView =getTabWidget().getChildAt(1);
               label1.setTextColor(Color.parseColor(GRAY));
               label1.setBackgroundResource(R.drawable.whitetab_background);
               label2.setTextColor(Color.parseColor(WHITE));
               label2.setBackgroundResource(R.drawable.bluetab_background);
            }
          }
        });
      }
      catch (Exception localException2)
      {

          localException2.printStackTrace();
          finish();

      }
    }
    catch (Exception localException1)
    {
      localException1.printStackTrace();
    }
  }
  @Override
    protected void onResume() {
        // TODO Auto-generated method stub
      back_button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
        }
    });
        super.onResume();
    }
  @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
    }
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/parent_clients_list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffffff"
    android:orientation="vertical" >

    <EditText
        android:id="@+id/con_search_button"
        android:layout_width="fill_parent"
        android:layout_height="40.0dip"
        android:layout_margin="5.0dip"
        android:background="@drawable/edbackground"
        android:drawableLeft="@drawable/search"
        android:drawablePadding="10.0dip"
        android:hint="search clients"
        android:textColor="@color/gray"
        android:textSize="15.0dip" />

    <ListView
        android:id="@+id/con_list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_margin="5.0dip"
        android:layout_weight="0.1"
        android:background="@android:color/white" />

</LinearLayout>
import java.util.ArrayList;
import pjsua2Utilies.AppData;
import commonUtilities.CommonUtility;
import commonUtilities.VariableClass;
import dto.Contacts;
import Adapter.AppContactListAdapter;
import Adapter.ContactListAdapter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.WindowManager.BadTokenException;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class AppContacts extends Activity {
    ListView contactslistview;
    EditText search_bar;
    ArrayList<Contacts>contactslist; 
    AppContactListAdapter adapter;
    Context c ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.contacts_list);
        initialise();
    }
    public void initialise()
    {
        contactslistview = (ListView)findViewById(R.id.con_list);
        search_bar = (EditText)findViewById(R.id.con_search_button);
        c = AppContacts.this;
    }
    @Override
    protected void onStart() {
        // TODO Auto-generated method stub
        new getContacts().execute(null,null,null);
        super.onStart();
    }
    @Override
    protected void onResume() {
        // TODO Auto-generated method stub

        contactslistview.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {

                if(AppData.reg_status){
                    Contacts dto = (Contacts)arg0.getItemAtPosition(arg2);
                    Intent i = new Intent(c, CallingScreen.class);
                    i.putExtra(VariableClass.Vari.NAMETOCALL,dto.getName());
                    i.putExtra(VariableClass.Vari.NUMBERTOCALL,dto.getNumber());
                    dto=null;
                    startActivity(i);
                }

            }
        });
        search_bar.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // TODO Auto-generated method stub
                String startwith=search_bar.getText().toString();
                ArrayList<Contacts>filterList=new ArrayList<Contacts>();
                int contactsCount=contactslist.size();
                for(int i=0;i<contactsCount;i++)
                {
                    if(contactslist.get(i).getName().startsWith(startwith) ||contactslist.get(i).getName().toLowerCase().startsWith(startwith) || contactslist.get(i).getName().toUpperCase().startsWith(startwith))
                    {
                        filterList.add(contactslist.get(i));

                    }
                }
                adapter=new AppContactListAdapter(c, filterList);
                contactslistview.setAdapter(adapter);
            }
            @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
            }
        });
        super.onResume();
    }
    class getContacts extends AsyncTask<Void,Void, Void>{
        String response=null;
        @Override
        protected void onPostExecute(Void result) {

            try {
                if(!((Activity)(c)).isFinishing())

                if(response.equals("1"))
                {

                }
                else if(response.equals("0")){}

                else{
                    if(contactslist==null&&contactslist.size()==0)
                        Toast.makeText(c, "No Contacts Found",2000).show();
                    else{
                        adapter=new AppContactListAdapter(c,contactslist);
                        contactslistview.setAdapter(adapter);
                    }
                }
            } catch (BadTokenException e) {
                // TODO: handle exception
            }
            catch (Exception e) {
                // TODO: handle exception
            }


            super.onPostExecute(result);
        }

        @Override
        protected void onPreExecute() {
            // TODO Auto-generated method stub

            contactslist=new ArrayList<Contacts>();
            try {
                new CommonUtility().show_PDialog(c, "Fetching Contacts..");

            } catch (BadTokenException e) {
                // TODO: handle exception
            }
            catch (Exception e) {
                // TODO: handle exception
            }

            super.onPreExecute();
        }

        @Override
        protected Void doInBackground(Void... params) {
            // TODO Auto-generated method stub
            response=Apis.getApisInstance(c).getContactsList("","");
            if(response.contains("{"))
            {
                contactslist=new JsonParser().getAllPhone91Contacts(response);
            }
            return null;
        }

    }
}

活动1代码:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/white" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#ffffffff"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@color/light_gray"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/back_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:gravity="left"
                android:padding="2.0dip"
                 android:layout_gravity="center_vertical"
                android:textColor="@color/blue"
                android:background="@android:color/transparent"
                android:text="Back"
                android:textStyle="bold"
                android:typeface="normal" />

            <TextView
                android:id="@+id/clientusername"
                android:layout_width="match_parent"
                android:layout_height="45.0dip"
                android:layout_gravity="center_horizontal"
                android:gravity="center_horizontal"
                android:padding="2.0dip"
                android:text="UserName Here"
                android:textColor="@color/blue"
                android:textSize="27.0dip"
                android:textStyle="bold"
                android:typeface="monospace" />

        </LinearLayout>

        <TabHost
            android:id="@android:id/tabhost"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginTop="10.0dip" >

            <LinearLayout
                android:id="@+id/tabcontainer"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical" >

                <TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="250.0dip"
                    android:layout_height="40.0dip"
                    android:layout_gravity="center"
                    android:gravity="center" />

                <FrameLayout
                    android:id="@android:id/tabcontent"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_marginTop="15.0dip"
                    android:background="@android:color/white"
                    android:fadeScrollbars="false"
                    android:fadingEdge="none"
                    android:scrollbars="none" />
            </LinearLayout>
        </TabHost>
    </LinearLayout>

</ScrollView>
import android.app.TabActivity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.TextView;
import commonUtilities.VariableClass;

public class ContactsGroup extends TabActivity
{
  private static LayoutInflater inflater;
  private static Intent intent;
  private static final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.5F);
  private static TabHost.TabSpec spec;
  private static TabHost tabHost;
  private String BLUE = "#296fa2";
  private String GRAY = "#929292";
  private String WHITE = "#FFFFFF";

  private TextView label1;
  private TextView label2;
  private View tab;
  TextView user_name;
  Button back_button;

  private void clearTabStyles()
  {
    for (int i = 0; ; i++)
    {
      if (i >= getTabWidget().getChildCount())
        return;
      this.tab = getTabWidget().getChildAt(i);
      this.tab.setBackgroundColor(Color.parseColor("#666666"));
    }
  }

  public void onBackPressed()
  {

    finish();
    super.onBackPressed();
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setContentView(R.layout.clients_tab);
    try
    {
      this.user_name = ((TextView)findViewById(R.id.clientusername));
      this.user_name.setTypeface(MainActivity.tp_semi_bold);
      back_button=(Button)findViewById(R.id.back_button);
      try
      {

        this.user_name.setVisibility(View.INVISIBLE);
        inflater = (LayoutInflater)getSystemService("layout_inflater");
        tabHost = getTabHost();
        this.tab = inflater.inflate(R.layout.tab, getTabWidget(), false);
        this.tab.setLayoutParams(params);
        this.label1 = ((TextView)this.tab.findViewById(R.id.tabLabel1));
        this.label1.setTypeface(MainActivity.tp_normal);
        this.label1.setText(VariableClass.Messages.APPCONTACTS);
        intent = new Intent(this, AppContacts.class);

        spec = tabHost.newTabSpec("home").setIndicator(this.tab).setContent(intent);
        tabHost.addTab(spec);
        this.tab = inflater.inflate(R.layout.tab, getTabWidget(), false);
        this.tab.setLayoutParams(params);
        this.label2 = ((TextView)this.tab.findViewById(R.id.tabLabel2));
        this.label2.setTypeface(MainActivity.tp_normal);
        this.label2.setText(VariableClass.Messages.ALLCONTACTS);
        intent = new Intent(this, PhoneContacts.class);

        spec = tabHost.newTabSpec("users").setIndicator(this.tab).setContent(intent);
        tabHost.addTab(spec);
        tabHost.setCurrentTab(0);
        getTabWidget().getChildAt(0).setBackgroundColor(-1);
        this.label1.setTextColor(Color.parseColor(this.WHITE));
        this.label1.setBackgroundResource(R.drawable.bluetab_background);
        this.label2.setTextColor(Color.parseColor(this.GRAY));
        this.label2.setBackgroundResource(R.drawable.whitetab_background);
        tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener()
        {
          public void onTabChanged(String paramAnonymousString)
          {
           clearTabStyles();
            View localView;
            if (paramAnonymousString.equals("home"))
            {
              localView =getTabWidget().getChildAt(0);
             label1.setTextColor(Color.parseColor(WHITE));
             label1.setBackgroundResource(R.drawable.bluetab_background);
             label2.setTextColor(Color.parseColor(GRAY));
             label2.setBackgroundResource(R.drawable.whitetab_background);
            }
            else if( paramAnonymousString.equals("users"))
            {
                localView =getTabWidget().getChildAt(1);
               label1.setTextColor(Color.parseColor(GRAY));
               label1.setBackgroundResource(R.drawable.whitetab_background);
               label2.setTextColor(Color.parseColor(WHITE));
               label2.setBackgroundResource(R.drawable.bluetab_background);
            }
          }
        });
      }
      catch (Exception localException2)
      {

          localException2.printStackTrace();
          finish();

      }
    }
    catch (Exception localException1)
    {
      localException1.printStackTrace();
    }
  }
  @Override
    protected void onResume() {
        // TODO Auto-generated method stub
      back_button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
        }
    });
        super.onResume();
    }
  @Override
    protected void onDestroy() {
        // TODO Auto-generated method stub
        super.onDestroy();
    }
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/parent_clients_list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffffff"
    android:orientation="vertical" >

    <EditText
        android:id="@+id/con_search_button"
        android:layout_width="fill_parent"
        android:layout_height="40.0dip"
        android:layout_margin="5.0dip"
        android:background="@drawable/edbackground"
        android:drawableLeft="@drawable/search"
        android:drawablePadding="10.0dip"
        android:hint="search clients"
        android:textColor="@color/gray"
        android:textSize="15.0dip" />

    <ListView
        android:id="@+id/con_list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_margin="5.0dip"
        android:layout_weight="0.1"
        android:background="@android:color/white" />

</LinearLayout>
import java.util.ArrayList;
import pjsua2Utilies.AppData;
import commonUtilities.CommonUtility;
import commonUtilities.VariableClass;
import dto.Contacts;
import Adapter.AppContactListAdapter;
import Adapter.ContactListAdapter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.WindowManager.BadTokenException;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class AppContacts extends Activity {
    ListView contactslistview;
    EditText search_bar;
    ArrayList<Contacts>contactslist; 
    AppContactListAdapter adapter;
    Context c ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.contacts_list);
        initialise();
    }
    public void initialise()
    {
        contactslistview = (ListView)findViewById(R.id.con_list);
        search_bar = (EditText)findViewById(R.id.con_search_button);
        c = AppContacts.this;
    }
    @Override
    protected void onStart() {
        // TODO Auto-generated method stub
        new getContacts().execute(null,null,null);
        super.onStart();
    }
    @Override
    protected void onResume() {
        // TODO Auto-generated method stub

        contactslistview.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {

                if(AppData.reg_status){
                    Contacts dto = (Contacts)arg0.getItemAtPosition(arg2);
                    Intent i = new Intent(c, CallingScreen.class);
                    i.putExtra(VariableClass.Vari.NAMETOCALL,dto.getName());
                    i.putExtra(VariableClass.Vari.NUMBERTOCALL,dto.getNumber());
                    dto=null;
                    startActivity(i);
                }

            }
        });
        search_bar.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                // TODO Auto-generated method stub
                String startwith=search_bar.getText().toString();
                ArrayList<Contacts>filterList=new ArrayList<Contacts>();
                int contactsCount=contactslist.size();
                for(int i=0;i<contactsCount;i++)
                {
                    if(contactslist.get(i).getName().startsWith(startwith) ||contactslist.get(i).getName().toLowerCase().startsWith(startwith) || contactslist.get(i).getName().toUpperCase().startsWith(startwith))
                    {
                        filterList.add(contactslist.get(i));

                    }
                }
                adapter=new AppContactListAdapter(c, filterList);
                contactslistview.setAdapter(adapter);
            }
            @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
            }
        });
        super.onResume();
    }
    class getContacts extends AsyncTask<Void,Void, Void>{
        String response=null;
        @Override
        protected void onPostExecute(Void result) {

            try {
                if(!((Activity)(c)).isFinishing())

                if(response.equals("1"))
                {

                }
                else if(response.equals("0")){}

                else{
                    if(contactslist==null&&contactslist.size()==0)
                        Toast.makeText(c, "No Contacts Found",2000).show();
                    else{
                        adapter=new AppContactListAdapter(c,contactslist);
                        contactslistview.setAdapter(adapter);
                    }
                }
            } catch (BadTokenException e) {
                // TODO: handle exception
            }
            catch (Exception e) {
                // TODO: handle exception
            }


            super.onPostExecute(result);
        }

        @Override
        protected void onPreExecute() {
            // TODO Auto-generated method stub

            contactslist=new ArrayList<Contacts>();
            try {
                new CommonUtility().show_PDialog(c, "Fetching Contacts..");

            } catch (BadTokenException e) {
                // TODO: handle exception
            }
            catch (Exception e) {
                // TODO: handle exception
            }

            super.onPreExecute();
        }

        @Override
        protected Void doInBackground(Void... params) {
            // TODO Auto-generated method stub
            response=Apis.getApisInstance(c).getContactsList("","");
            if(response.contains("{"))
            {
                contactslist=new JsonParser().getAllPhone91Contacts(response);
            }
            return null;
        }

    }
}
import java.util.ArrayList;
导入pjsua2utiles.AppData;
导入commonUtilities.CommonUtility;
导入commonUtilities.VariableClass;
输入数据到通讯录;
导入适配器。AppContactListAdapter;
导入适配器。ContactListAdapter;
导入android.app.Activity;
导入android.content.Context;
导入android.content.Intent;
导入android.os.AsyncTask;
导入android.os.Bundle;
导入android.text.Editable;
导入android.text.TextWatcher;
导入android.view.view;
导入android.view.WindowManager.BadTokenException;
导入android.widget.AdapterView;
导入android.widget.EditText;
导入android.widget.ListView;
导入android.widget.Toast;
导入android.widget.AdapterView.OnItemClickListener;
公共类AppContacts扩展活动{
列表视图联系人列表视图;
编辑文本搜索栏;
ArrayListcontactslist;
AppContactListAdapter;
上下文c;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
//TODO自动生成的方法存根
super.onCreate(savedInstanceState);
setContentView(R.layout.contacts_列表);
初始化();
}
公开无效初始化()
{
contactslistview=(ListView)findViewById(R.id.con_列表);
搜索栏=(编辑文本)findViewById(R.id.con\u搜索按钮);
c=AppContacts.this;
}
@凌驾
受保护的void onStart(){
//TODO自动生成的方法存根
new getContacts().execute(null,null,null);
super.onStart();
}
@凌驾
受保护的void onResume(){
//TODO自动生成的方法存根
contactslistview.setOnItemClickListener(新的OnItemClickListener(){
@凌驾
公共链接(AdapterView arg0、视图arg1、内部arg2、,
长arg3){
if(AppData.reg_状态){
联系人dto=(联系人)arg0.getItemAtPosition(arg2);
意图i=新意图(c,CallingScreen.class);
i、 putExtra(VariableClass.Vari.NAMETOCALL,dto.getName());
i、 putExtra(VariableClass.Vari.NUMBERTOCALL,dto.getNumber());
dto=null;
星触觉(i);
}
}
});
search_bar.addTextChangedListener(新的TextWatcher(){
@凌驾
public void onTextChanged(字符序列、int start、int before、int count){
//TODO自动生成的方法存根
String startwith=search_bar.getText().toString();
ArrayListfilterList=新的ArrayList();
int contactsCount=contactslist.size();

对于ScrollView中的(inti=0;iListView,这正是您的问题所在

父ScrollView将不接受ListView作为其子级。您只需处理布局xml的ListView子级

请参阅:
android:fillViewport=“true”
将这一行添加到ScrollView通常你不应该将两个垂直可滚动的视图嵌套在一起。你不需要根
ScrollView
。ScrollView中的ListView就是你的问题。请参考这一点以及ScrollView中ListView不起作用的另一件事,请参见此处:@ShabbirDhangot在应用该列表后在com上显示关闭屏幕,但仍然无法滚动。