Q:

android list view is not being shown on 4.1.2 version

I have a list view inside a ViewSwitcher that works fine in android version 2.2 but it does not show in my device which has android 4.1.2 version.
I also debugg it and dont see any errors, and also checked to see if the list I pass to adapter is not null, and saw that it was not empty.
I have another list view which is located in a TabHost that is being shown correctly.
Regards
Edited:
Here is my code:
<ViewSwitcher xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/viewswitcher"
        android:layout_gravity="center"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:scrollbars="vertical"
    android:layout_gravity="center|top"
     >

    <TextView
        android:id="@+id/dateLbl"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:text="@string/lblChooseaDate" />

    <DatePicker
        android:id="@+id/datePicker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:layout_gravity="center" />

    <Button
        android:id="@+id/btnChooseDate"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:text="@string/startdayexpensebtn" />
</LinearLayout>
<LinearLayout
      android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:scrollbars="vertical"
     >
    <TextView
        android:id="@+id/descLbl"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="20dp"
        android:text="@string/lbldaydescription" />

    <EditText
        android:id="@+id/dayDesctiptionText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:singleLine="false"
        android:minLines="1"
        android:maxLines="3"
        android:inputType="textMultiLine" />

    <Button
        android:id="@+id/addnewItem"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:enabled="false"
        android:text="@string/btnAddnewItem" />

    <LinearLayout
        android:id="@+id/listcontaioner"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:scrollbars="vertical"
        >
    <ListView
        android:id="@+id/android:list"
        android:divider="#bababa"
        android:dividerHeight="1dp"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_margin="10dp" >
    </ListView>
</LinearLayout>

    <LinearLayout
        android:id="@+id/btnlinearlayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_gravity="bottom"
        android:paddingRight="10dp"
        android:paddingLeft="10dp" >

        <Button
            android:id="@+id/cancelbtn"
            android:layout_weight="2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/btncancel" />
         <Button
            android:id="@+id/savebtn"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/btnAdd" />
    </LinearLayout>

</LinearLayout>
</ViewSwitcher>

also for each row:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/linearLayout1"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="50dp" >

        <ImageView
            android:id="@+id/expenselisitem_imgaetype"
            android:layout_width="28dp"
            android:layout_height="28dp"
            android:layout_marginLeft="5dp"
            android:layout_marginBottom="35dp"
            android:src="@drawable/fail" />

        <RelativeLayout
            android:id="@+id/relativeLayout1"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <TextView
                android:id="@+id/expenselisitem_desc"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentTop="true"
                android:text="Medium Text"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:id="@+id/expenselisitem_category"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_alignParentLeft="true"
                android:layout_below="@+id/expenselisitem_desc"
                android:paddingBottom="6dp"
                android:text="Small Text"
                android:textAppearance="?android:attr/textAppearanceSmall" />

            <TextView
                android:id="@+id/expenselisitem_amount"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_alignBaseline="@+id/expenselisitem_category"
                android:layout_alignBottom="@+id/expenselisitem_category"
                android:layout_alignParentRight="true"
                android:layout_marginRight="14dp"
                android:paddingBottom="6dp"
                android:text="Small Text"
                android:textAppearance="?android:attr/textAppearanceSmall" />

        </RelativeLayout>

    </LinearLayout>

and here is the adapter:
    public class CustomAddExpenseItemListAdapter extends BaseAdapter {

    private ArrayList<ExpenseItem> _list=new ArrayList<ExpenseItem>();

    private final Activity _context;
    private static LayoutInflater inflater=null;

    public CustomAddExpenseItemListAdapter(Activity activity,ArrayList<ExpenseItem> data){

        _list  = data;
        _context=activity;
    }

    public long getItemId(int position) {
        return position;
    }

    public int getCount() {
        return _list.size();
    }

    public Object getItem(int position) {
        return position;
    }

    static class ViewHolder {
        protected TextView _cexpenseDesctiption;
        protected TextView _cAmount;
        protected ImageView _cType;
        protected TextView _cCategory;

    }

    public View getView(int position, View convertView, ViewGroup parent) {
        View vi=null;

        if(convertView==null)
        {
            inflater = _context.getLayoutInflater();
            vi = inflater.inflate(R.layout.expense_item_list_row, null);
            final ViewHolder viewHolder = new ViewHolder();
            viewHolder._cexpenseDesctiption= (TextView) vi.findViewById(R.id.expenselisitem_desc);
            viewHolder._cAmount = (TextView) vi.findViewById(R.id.expenselisitem_amount);
            viewHolder._cType=(ImageView)vi.findViewById(R.id.expenselisitem_imgaetype);
            viewHolder._cCategory=(TextView)vi.findViewById(R.id.expenselisitem_category);

            vi.setTag(viewHolder);
        }
        else
        {
            vi = convertView;
        }

        ViewHolder holder = (ViewHolder) vi.getTag();

        ExpenseItem item;
        item = _list.get(position);

        holder._cexpenseDesctiption.setText(item.get_description());
        holder._cAmount.setText(String.valueOf(item.get_amount()));

        if(item.get_type()==0)
        {
            holder._cCategory.setText(item.get_category().get_title());
            holder._cType.setImageResource(R.drawable.downarrow);
        }
        else
        {
            holder._cCategory.setText("-");
            holder._cType.setImageResource(R.drawable.uparrow);
        }

        return vi;
    }

}

A:

Usually this is solved by wrapping the ListView inside a LineaLayout or RelativeLayout but depending on the problem you've countered the solution might be something entirely different. 
Here is a working example of a ViewSwitcher that switches between a ListView and TextView.
From the following XML text you can see that ListView has been wrapped in a RelativeLayout together with a Button that enables the switch between the views(layouts).
<RelativeLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".MainActivity">

    <ViewSwitcher
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id = "@+id/viewswitcher"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"

    >
    <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
    >
        <Button
                android:id="@+id/btn_next"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:text="Show Next" />
        <ListView android:id="@+id/listview" android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:layout_alignParentTop="true"
                  android:layout_above="@id/btn_next"></ListView>

     </RelativeLayout>
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <TextView
            android:id="@+id/text"
            android:layout_height="fill_parent"
            android:layout_width="wrap_content"
            android:text="HEllO WORLD">

            </TextView>

        <Button
                android:id="@+id/btn_previous"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Show Previous" />
     </LinearLayout>

        </ViewSwitcher>

</RelativeLayout>

And here is the Java code that delivers the magic:
public class MainActivity extends Activity {

    ViewSwitcher mViewSwitcher;

    ListView listview;
    String[] values = new String[] { "Hello1", "Hello2", "Hello3",
        "Hello4", "Hello5", "Hello6", "Hello7", "Hello8",
        "Hello9", "Hello10", "Hello11", "Hello12", "Hello13", "Hello14",
        "Hello15"};

    Button shownext;
    Button showprevious;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mViewSwitcher = (ViewSwitcher)findViewById(R.id.viewswitcher);
        listview = (ListView) findViewById(R.id.listview);
        shownext = (Button)findViewById(R.id.btn_next);
        showprevious = (Button)findViewById(R.id.btn_previous);

        shownext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mViewSwitcher.showNext();
            }
        });

        showprevious.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mViewSwitcher.showPrevious();
            }
        });

        final ArrayList<String> list = new ArrayList<String>();
        for (int i = 0; i < values.length; ++i) {
            list.add(values[i]);
        }
        final StableArrayAdapter adapter = new StableArrayAdapter(this,
                android.R.layout.simple_list_item_1, list);
        listview.setAdapter(adapter);

    }

    private class StableArrayAdapter extends ArrayAdapter<String> {

        HashMap<String, Integer> mIdMap = new HashMap<String, Integer>();

        public StableArrayAdapter(Context context, int textViewResourceId,
                                  List<String> objects) {
            super(context, textViewResourceId, objects);
            for (int i = 0; i < objects.size(); ++i) {
                mIdMap.put(objects.get(i), i);
            }
        }

        @Override
        public long getItemId(int position) {
            String item = getItem(position);
            return mIdMap.get(item);
        }

        @Override
        public boolean hasStableIds() {
            return true;
        }

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

This has been tested successfully on Android 4.1.2.
Hope that helps!

