user3119647
user3119647

Reputation: 191

Android :xml file not working

i am new to android and facing some problem with xml , i added some basic code in xml file and set view to this xml file (edit_task.xml) like this

public class EditTask extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.edit_task);
    }

code in edit_task.xml is like this

 <ScrollView 
        xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

       <LinearLayout android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >

           <TextView
            android:text="@string/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             />
        <EditText 

            android:id="@+id/title"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            />
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
             android:text="@string/body"
             />
        <EditText 
            android:id="@+id/body"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:minLines="5"
            android:scrollbars="vertical"
           android:gravity="top" /> 

        <TextView 
           android:text="@string/date"

           android:layout_width="fill_parent"
           android:layout_height="wrap_content"

            />
        <Button 
            android:id="@+id/reminder_time"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/Reminder_Time"
            />

        <TextView 
            android:text="@string/time"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            />
        <Button 
            android:id="@+id/remindertime"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/remindertime"
            />

        <Button 
            android:id="@+id/confirm"
            android:text="@string/confirm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            />

       </LinearLayout>

     </ScrollView>

now when i compile this it shows hello world instead of this xml , Hello world id added in my strings.xml but its not being pointed in above mentioned xml , so whats wrong with it , please guide me about it ..

This is how i added it to Manifest.xml

<activity
 android:name="com.example.mytastreminder.EditTask"
 android:label="@string/app_name" >

 </activity>

Upvotes: 0

Views: 622

Answers (1)

Blo
Blo

Reputation: 11978

In your Manifest, change this:

<activity
   android:name=".HelloAndroidActivity"
   android:label="@string/title_activity_hello_android" >
   <intent-filter>
       <action android:name="android.intent.action.MAIN" />

       <category android:name="android.intent.category.LAUNCHER"/>
   </intent-filter>
</activity>  

By:

<activity
   android:name=".EditTask "
   android:label="@string/app_name" >
   <intent-filter>
       **<action android:name="android.intent.action.MAIN" />**

       **<category android:name="android.intent.category.LAUNCHER"/>**
   </intent-filter>
</activity>  

You need to set the action/category of your Activity. In the example above, you say EditTask is the Main Activity of your application and also, it's the Activity which is displayed when you Launch the app.
Only one activity can have this specific action/category. They can also have other action like: VIEW, EDIT, SEARCH, etc. But only one have this above.

Upvotes: 2

Related Questions