1

Hi i'm having a problem with my android app. The problem is when i try to set up new view.

    public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
        if (v == null) {
            try{
            LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.list, null);
            }
            catch(Exception e){
                String a=e.toString();
            }
        } 

in line v = vi.inflate(R.layout.list, null); i get this error:

    android.view.InflateException: Binary XML file line #5: Error inflating class <unknown> 

Here is also my list.xml file:

    <?xml version="1.0" encoding="utf-8"?>
    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="15dp"
        android:background="@drawable/bg_seznam" >
        <TextView
            android:id="@+id/item_title"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="17dp"
            android:textColor="#ffffff"
            android:textSize="20dp"
            android:textStyle="bold"
            android:typeface="serif" >
        </TextView>         
    </TableRow>
    </TableLayout>

So any ideas?

gabrjan
  • 3,080
  • 9
  • 40
  • 69

2 Answers2

1

Try to replace this line of your code

v = vi.inflate(R.layout.list, null);

by this one:

v = vi.inflate(R.layout.list, parent, false);
StenaviN
  • 3,687
  • 24
  • 34
  • How `bg_seznam` drawable looks like? Is it an image or xml drawable? – StenaviN Aug 07 '12 at 14:07
  • wow i tryied it on other phone and it's working normaly... I want to know now why isn't it working on first phone :S – gabrjan Aug 07 '12 at 14:15
  • btw first one is 2.1 amd second is 2.2 my this be a problem? The minimum for application is level 7 and it's build for level 15. – gabrjan Aug 07 '12 at 14:24
1

I tried your code and it works fine on my side.
Perhaps doing a clean would help: Project -> Clean -> Select your project -> OK.

Andy Res
  • 15,963
  • 5
  • 60
  • 96