2

having a trouble here with the sliding tabs. So I have completed the tutorial but when i had a ListView to my Pager it only shows on the bottom of the screen.

Here is my XML:

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

    <com.example.ambidata.innovway.SlidingTabLayout
        android:id="@+id/sliding_tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_weight="1"
        android:background="@android:color/white"/>

</LinearLayout>

And my XML from ListView:

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

    <ListView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/issue_list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:divider="@color/list_divider"
        android:dividerHeight="1dp"
        android:listSelector="@drawable/list_row_selector"/>

</LinearLayout>

Fragment Code:

public class TabIssues extends Fragment {

    private ListView mainListView ;
    private CustomListAdapter_Issues listAdapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {

        Bundle b = getArguments();
        int user_id = b.getInt("user_id");
        boolean all = b.getBoolean("all");

        WSConnectionIssues runner = new WSConnectionIssues(user_id, all);

        runner.execute();

        while (runner.download == AsyncTask.Status.RUNNING)
        {
            try
            {
                Thread.sleep(1);
            } catch (Exception ex)
            {
                ex.printStackTrace();
            }
        }

        View view = inflater.inflate(R.layout.activity_issues, container, false);
        // Find the ListView resource.
        mainListView = (ListView) view.findViewById(R.id.issue_list);
        registerForContextMenu(mainListView);

        // Create ArrayAdapter using the planet list.
        View convertView = inflater.inflate(R.layout.row_issues, null);
        listAdapter = new CustomListAdapter_Issues(this, runner.listIssues, convertView);
        // Set the ArrayAdapter as the ListView's adapter.
        mainListView.setAdapter(listAdapter);
        return view;
    }

BUG Im using the phone for debug...as you can see blank...then the first item of my listview and if you scroll the others are there!

Mycoola
  • 1,135
  • 1
  • 8
  • 29
Jorge Cruz
  • 21
  • 3
  • even not 'fill_parent' reason, but it is depreciated. Your listview layout should be for fragment, right? so check your fragment 'onCreateView' is crrect? – Xcihnegn Jan 24 '15 at 19:57
  • Gonna put my Fragment code on question – Jorge Cruz Jan 24 '15 at 20:00
  • and also the 'convertView' normally processed in the adapter 'getView' – Xcihnegn Jan 24 '15 at 20:15
  • maybe you could show your screenshot – Xcihnegn Jan 24 '15 at 22:56
  • the image on question – Jorge Cruz Jan 24 '15 at 23:06
  • @JorgeCruz Just to improve the post, now, or for the future ones, if you are using Eclipse, you have the option of "DDMS", where you will have the list of devices connected. If you chosse (in these case) your phone, you will have some options, one (camera icon) is to take a screenshot from what is shown in your device ;). In Android Studio is the same ^^ ---> http://stackoverflow.com/questions/6421108/screenshots-with-idea-intellij – Shudy Jan 26 '15 at 12:08

1 Answers1

0

Could you try the listview layout as:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical" >

   <ListView         
      android:id="@+id/issue_list"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:divider="@color/list_divider"
      android:dividerHeight="1dp"
      android:listSelector="@drawable/list_row_selector"/>

</RelativeLayout>
Xcihnegn
  • 11,579
  • 10
  • 33
  • 33