- Forum-Beiträge: 2
25.11.2013, 11:18:56 via App
25.11.2013 11:18:56 via App
ich bin dabei eine app zu entwickeln. in drr Main xml kann man auf einen Button drücken, aber wenn man ihn drückt hängt sich das handy auf. warum:
hier die main.xml:
2<LinearLayout xmlns:android="h ttp://schemas.android.com/apk/res/android"
3 android:layout_width="fill_parent"
4 android:layout_height="fill_parent"
5 android:gravity="center"
6 android:orientation="vertical" >
7
8 <TextView
9 android:layout_width="wrap_content"
10 android:layout_height="wrap_content"
11 android:text="@string/hello" />
12 <Button
13 android:id="@+id/button1"
14 android:layout_width="fill_parent"
15 android:layout_height="wrap_content"
16 android:layout_alignParentLeft="true"
17 android:layout_below="@+id/editText4"
18 android:layout_marginTop="20dp"
19 android:onClick="onClickButton"
20 android:text="menu"/>
21
22
23 </LinearLayout>
sec.xml:
2<LinearLayout
3xmlns:android="h ttp://schemas.android.com/apk/res/android"
4 android:layout_width="fill_parent"
5 android:layout_height="fill_parent"
6 android:orientation="vertical">
7
8 <TextView
9 android:text="hello"/>
10
11</LinearLayout>
mainactivity.java(activiti von main):
2
3import android.app.*;
4import android.content.*;
5import android.os.*;
6import android.view.*;
7
8public class MainActivity extends Activity
9{
10 /** Called when the activity is first created. */
11 @Override
12 public void onCreate(Bundle savedInstanceState)
13 {
14 super.onCreate(savedInstanceState);
15 setContentView(R.layout.main);
16 }
17 public void onClickButton (View view) {
18 Intent intent = new Intent (this, activizi.class);
19 startActivity(intent); finish();
20}}
manifest.xml
2<manifest xmlns:android="h ttp://schemas.android.com/apk/res/android"
3 package="com.mycompany.myapp8"
4 android:versionCode="1"
5 android:versionName="1.0" >
6
7 <uses-sdk
8 android:minSdkVersion="8"
9 android:targetSdkVersion="11" />
10
11 <application
12 android:icon="@drawable/ic_launcher"
13 android:label="@string/app_name" >
14 <activity
15 android:label="@string/app_name"
16 android:name=".MainActivity" >
17 <intent-filter >
18 <action android:name="android.intent.action.MAIN" />
19
20 <category android:name="android.intent.category.LAUNCHER" />
21 </intent-filter>
22 </activity>
23 <activity
24 android:label="@string/app_name"
25 android:name=".activizi" >
26 </activity>
27 </application>
28
29</manifest>
falls noch ein wichtiger code fehlt einfach schreiben.
— geändert am 25.11.2013, 13:57:11
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.