I have made a android app in Eclipse. Now I want to change the Default layout -


i have set layout test app

<activity             android:name="com.example.test.testactivity"             android:label="@string/app_name" >             <intent-filter>                 <action android:name="android.intent.action.main" />                  <category android:name="android.intent.category.launcher" />             </intent-filter>         </activity> 

when run it's not take testactivity. have run (run app) many time. it's take mainactivity. know how modified it.

if need somewhere please tell me. want change app run testactivity instead of mainactivity

<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:paddingbottom="@dimen/activity_vertical_margin"     android:paddingleft="@dimen/activity_horizontal_margin"     android:paddingright="@dimen/activity_horizontal_margin"     android:paddingtop="@dimen/activity_vertical_margin"     tools:context=".testactivity" >      <button         android:id="@+id/button1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_alignparentright="true"         android:layout_alignparenttop="true"         android:layout_marginright="36dp"         android:layout_margintop="152dp" android:onclick="btntest"         android:text="button" />   </relativelayout> 

activity:

public class testactivity extends activity {      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);     }       @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.main, menu);         return true;     }       public arraylist<string> getarray(string input){         arraylist<string> arr=  new arraylist<string>();          return arr;     }     public void btntest(view view){         toast.maketext(getapplicationcontext(), "this test", toast.length_short);     } } 

your problem have setted same layout both of activities .

in activity testactivity , in oncreate() method ;you should set content view :

setcontentview(r.layout.test_activity); 

instead of :

setcontentview(r.layout.activity_main); 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -