0

hi in my app i am trying to make an text view and edit box in a same line as if in iPhone apps.

after getting some info in the following link How can I implement this UI in Android,

i created the two xml file. the following is my main.xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="vertical"
      android:background="@drawable/back"
      android:layout_marginRight="10dp"
      android:layout_marginBottom="10dp"
      android:layout_marginTop="20dp"
      xmlns:android="http://schemas.android.com/apk/res/android">
   <LinearLayout android:layout_width="fill_parent"
                 android:layout_height="wrap_content"
                 android:orientation="horizontal"
                 android:paddingLeft="10dp">


      <TextView android:text="Initial"
                android:textColor="#686868"
                android:id="@+id/wideget02"
                android:textSize="10sp"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content">
      </TextView>

      <EditText android:id="@+id/widget01"
                android:layout_width="fill_parent"
                android:layout_height="35dp"
                android:singleLine="true"
                android:inputType="textEmailAddress"
                android:textSize="15sp"
                android:background="@android:color/transparent" android:hint="Initial"/>
   </LinearLayout>

   <View android:layout_width="fill_parent" android:layout_height="1dip"
         android:background="#ababab"/>

   <LinearLayout android:layout_width="fill_parent"
                 android:layout_height="wrap_content" android:orientation="horizontal"
                 android:paddingLeft="10dp">
      <TextView android:text="Initial" android:textColor="#686868"
                android:id="@+id/widget02" android:textSize="10sp" android:layout_width="fill_parent"
                android:layout_height="wrap_content"
            ></TextView>

      <EditText android:id="@+id/widget01" android:layout_width="fill_parent"
                android:layout_height="35dp" android:singleLine="true"
                android:inputType="textEmailAddress" android:textSize="15sp"
                android:background="@android:color/transparent" android:hint="Initial"/>
   </LinearLayout>
</LinearLayout>

Following is the back.xml file which i have placed in drawable of resource folder

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

   <stroke android:width="1dp" android:color="#ababab"/>

   <padding android:left="1dp"
            android:top="1dp"
            android:right="1dp"
            android:bottom="1dp"
         />

   <corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp"
            android:topLeftRadius="7dp" android:topRightRadius="7dp"/>

</LinearLayout> 

When i run the app it shows the following errors in logcat

03-24 11:51:40.191: ERROR/AndroidRuntime(638): Caused by: android.view.InflateException: Binary XML file line #3: Error inflating class java.lang.reflect.Constructor
03-24 11:51:40.191: ERROR/AndroidRuntime(638):     at android.view.LayoutInflater.createView(LayoutInflater.java:512)
03-24 11:51:40.191: ERROR/AndroidRuntime(638):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
03-24 11:51:40.191: ERROR/AndroidRuntime(638):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562)
03-24 11:51:40.191: ERROR/AndroidRuntime(638):     at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
03-24 11:51:40.191: ERROR/AndroidRuntime(638):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
03-24 11:51:40.191: ERROR/AndroidRuntime(638):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
03-24 11:51:40.191: ERROR/AndroidRuntime(638):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:318)
03-24 11:51:40.191: ERROR/AndroidRuntime(638):     at android.app.Activity.setContentView(Activity.java:1631)
03-24 11:51:40.191: ERROR/AndroidRuntime(638):     at com.gis.ss.main.onCreate(main.java:16)
03-24 11:51:40.191: ERROR/AndroidRuntime(638):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1132)
03-24 11:51:40.191: ERROR/AndroidRuntime(638):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
03-24 11:51:40.191: ERROR/AndroidRuntime(638):     ... 11 more`

what it refers too, please explain me..

3
  • hey where is your back.xml ? i cant see it . Commented Mar 24, 2011 at 6:47
  • sorry here it is <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <stroke android:width="1dp" android:color="#ababab" /> <padding android:left="1dp" android:top="1dp" android:right="1dp" android:bottom="1dp" /><corners android:bottomRightRadius="7dp" android:bottomLeftRadius="7dp" android:topLeftRadius="7dp" android:topRightRadius="7dp"/> </LinearLayout> Commented Mar 24, 2011 at 7:06
  • hi Chirag using ur example i am able to create the same view, but i cant type anything there. how to type in the edit box...... Commented Mar 24, 2011 at 8:09

1 Answer 1

1

The root element of your back drawable must not be a LinearLayout. Looks like you need a shape there.

See this doc

Sign up to request clarification or add additional context in comments.

2 Comments

hi using ur link i am able clear my error, but i cant type anything there. how to type in the edit box......
As you can see in the first xml part ie main.xml file, i have placed an edit text box, i am not able to type anything there

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.