Fehler beim Starten einer zweiten Activity

  • Antworten:4
  • OffenNicht stickyNicht beantwortet
  • Forum-Beiträge: 4

21.06.2014, 22:12:20 via Website

Ich habe ein Problem beim Starten einer zweiten Activity. Als Orientierung nutze ich das Tutorial von "developer.android.com". Ich verstehe nicht wo genau der Fehler liegt bzw. wie ich ihn aufheben kann. Falls noch irgendwelchen Infos benötigt werden sagt bitte Bescheid. Ich weiß nicht was für so eine Fehlerfindung benötigt wird.

Der LogCat zeigt mir dies an:
06-21 14:52:35.320: I/Choreographer(951): Skipped 38 frames! The application may be doing too much work on its main thread.
06-21 14:52:35.840: I/Choreographer(951): Skipped 277 frames! The application may be doing too much work on its main thread.
06-21 14:52:43.640: I/Choreographer(951): Skipped 43 frames! The application may be doing too much work on its main thread.
06-21 14:53:10.757: I/Choreographer(951): Skipped 78 frames! The application may be doing too much work on its main thread.
06-21 14:53:11.077: E/FragmentManager(951): No view found for id 0x7f05003c (com.example.myfirstapp:id/container) for fragment PlaceholderFragment{b2d5b138 #0 id=0x7f05003c}
06-21 14:53:11.077: E/FragmentManager(951): Activity state:
06-21 14:53:11.077: D/FragmentManager(951): Local FragmentActivity b2d51268 State:
06-21 14:53:11.087: D/FragmentManager(951): mCreated=truemResumed=false mStopped=false mReallyStopped=false
06-21 14:53:11.087: D/FragmentManager(951): mLoadersStarted=false
06-21 14:53:11.087: D/FragmentManager(951): Active Fragments in b2d514d8:
06-21 14:53:11.087: D/FragmentManager(951): #0: PlaceholderFragment{b2d5b138 #0 id=0x7f05003c}
06-21 14:53:11.087: D/FragmentManager(951): mFragmentId=#7f05003c mContainerId=#7f05003c mTag=null
06-21 14:53:11.087: D/FragmentManager(951): mState=0 mIndex=0 mWho=android:fragment:0 mBackStackNesting=0
06-21 14:53:11.087: D/FragmentManager(951): mAdded=true mRemoving=false mResumed=false mFromLayout=false mInLayout=false
06-21 14:53:11.087: D/FragmentManager(951): mHidden=false mDetached=false mMenuVisible=true mHasMenu=false
06-21 14:53:11.087: D/FragmentManager(951): mRetainInstance=false mRetaining=false mUserVisibleHint=true
06-21 14:53:11.087: D/FragmentManager(951): mFragmentManager=FragmentManager{b2d514d8 in DisplayMessageActivity{b2d51268}}
06-21 14:53:11.087: D/FragmentManager(951): mActivity=com.example.myfirstapp.DisplayMessageActivity@b2d51268
06-21 14:53:11.087: D/FragmentManager(951): Added Fragments:
06-21 14:53:11.147: D/FragmentManager(951): #0: PlaceholderFragment{b2d5b138 #0 id=0x7f05003c}
06-21 14:53:11.157: D/FragmentManager(951): FragmentManager misc state:
06-21 14:53:11.157: D/FragmentManager(951): mActivity=com.example.myfirstapp.DisplayMessageActivity@b2d51268
06-21 14:53:11.157: D/FragmentManager(951): mContainer=android.support.v4.app.FragmentActivity$2@b2d51550
06-21 14:53:11.217: D/FragmentManager(951): mCurState=2 mStateSaved=false mDestroyed=false
06-21 14:53:11.217: D/FragmentManager(951): View Hierarchy:
06-21 14:53:11.217: D/FragmentManager(951): com.android.internal.policy.impl.PhoneWindow$DecorView{b2d53468 V.E..... ... 0,0-0,0}
06-21 14:53:11.227: D/FragmentManager(951): com.android.internal.widget.ActionBarOverlayLayout{b2d53b28 V.ED.... ... 0,0-0,0 #1020313 android:id/action_bar_overlay_layout}
06-21 14:53:11.227: D/FragmentManager(951): android.widget.FrameLayout{b2d547b8 V.E..... ... 0,0-0,0 #1020002 android:id/content}
06-21 14:53:11.227: D/FragmentManager(951): android.widget.TextView{b2d52fe8 V.ED.... ... 0,0-0,0}
06-21 14:53:11.267: D/FragmentManager(951): com.android.internal.widget.ActionBarContainer{b2d54c38 V.ED.... ... 0,0-0,0 #1020314 android:id/action_bar_container}
06-21 14:53:11.267: D/FragmentManager(951): com.android.internal.widget.ActionBarView{b2d551c0 V.E..... ... 0,0-0,0 #1020315 android:id/action_bar}
06-21 14:53:11.317: D/FragmentManager(951): android.widget.LinearLayout{b2d557b0 VFE...C. ... 0,0-0,0}
06-21 14:53:11.347: D/FragmentManager(951): com.android.internal.widget.ActionBarView$HomeView{b2d56910 V.E..... ... 0,0-0,0}
06-21 14:53:11.347: D/FragmentManager(951): android.widget.ImageView{b2d56d28 V.ED.... ... 0,0-0,0 #102025a android:id/up}
06-21 14:53:11.347: D/FragmentManager(951): android.widget.ImageView{b2d57108 V.ED.... ... 0,0-0,0 #102002c android:id/home}
06-21 14:53:11.357: D/FragmentManager(951): android.widget.LinearLayout{b2d58500 G.E..... ... 0,0-0,0}
06-21 14:53:11.357: D/FragmentManager(951): android.widget.TextView{b2d58898 V.ED.... ... 0,0-0,0 #1020265 android:id/action_bar_title}
06-21 14:53:11.357: D/FragmentManager(951): android.widget.TextView{b2d595a0 G.ED.... ... 0,0-0,0 #1020266 android:id/action_bar_subtitle}
06-21 14:53:11.407: D/FragmentManager(951): com.android.internal.widget.ActionBarContextView{b2d59c40 G.E..... ... 0,0-0,0 #1020316 android:id/action_context_bar}
06-21 14:53:11.407: D/FragmentManager(951): com.android.internal.widget.ActionBarContainer{b2d5a190 G.ED.... ... 0,0-0,0 #1020317 android:id/split_action_bar}
06-21 14:53:11.417: D/AndroidRuntime(951): Shutting down VM
06-21 14:53:11.417: W/dalvikvm(951): threadid=1: thread exiting with uncaught exception (group=0xb2a4fba8)
06-21 14:53:11.567: E/AndroidRuntime(951): FATAL EXCEPTION: main
06-21 14:53:11.567: E/AndroidRuntime(951): Process: com.example.myfirstapp, PID: 951
06-21 14:53:11.567: E/AndroidRuntime(951): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myfirstapp/com.example.myfirstapp.DisplayMessageActivity}: java.lang.IllegalArgumentException: No view found for id 0x7f05003c (com.example.myfirstapp:id/container) for fragment PlaceholderFragment{b2d5b138 #0 id=0x7f05003c}
06-21 14:53:11.567: E/AndroidRuntime(951): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
06-21 14:53:11.567: E/AndroidRuntime(951): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
06-21 14:53:11.567: E/AndroidRuntime(951): at android.app.ActivityThread.access$800(ActivityThread.java:135)
06-21 14:53:11.567: E/AndroidRuntime(951): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
06-21 14:53:11.567: E/AndroidRuntime(951): at android.os.Handler.dispatchMessage(Handler.java:102)
06-21 14:53:11.567: E/AndroidRuntime(951): at android.os.Looper.loop(Looper.java:136)
06-21 14:53:11.567: E/AndroidRuntime(951): at android.app.ActivityThread.main(ActivityThread.java:5017)
06-21 14:53:11.567: E/AndroidRuntime(951): at java.lang.reflect.Method.invokeNative(Native Method)
06-21 14:53:11.567: E/AndroidRuntime(951): at java.lang.reflect.Method.invoke(Method.java:515)
06-21 14:53:11.567: E/AndroidRuntime(951): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
06-21 14:53:11.567: E/AndroidRuntime(951): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
06-21 14:53:11.567: E/AndroidRuntime(951): at dalvik.system.NativeStart.main(Native Method)
06-21 14:53:11.567: E/AndroidRuntime(951): Caused by: java.lang.IllegalArgumentException: No view found for id 0x7f05003c (com.example.myfirstapp:id/container) for fragment PlaceholderFragment{b2d5b138 #0 id=0x7f05003c}
06-21 14:53:11.567: E/AndroidRuntime(951): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:919)
06-21 14:53:11.567: E/AndroidRuntime(951): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
06-21 14:53:11.567: E/AndroidRuntime(951): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
06-21 14:53:11.567: E/AndroidRuntime(951): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
06-21 14:53:11.567: E/AndroidRuntime(951): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:570)
06-21 14:53:11.567: E/AndroidRuntime(951): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
06-21 14:53:11.567: E/AndroidRuntime(951): at android.app.Activity.performStart(Activity.java:5241)
06-21 14:53:11.567: E/AndroidRuntime(951): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2168)
06-21 14:53:11.567: E/AndroidRuntime(951): ... 11 more
06-21 14:53:11.757: D/dalvikvm(951): GC_FOR_ALLOC freed 219K, 9% free 2993K/3280K, paused 172ms, total 179ms
06-21 14:53:17.987: I/Process(951): Sending signal. PID: 951 SIG: 9

Antworten
Pascal P.
  • Mod
  • Blogger
  • Forum-Beiträge: 10.165

22.06.2014, 17:24:59 via Website

No view found for id 0x7f05003c (com.example.myfirstapp:id/container) for fragment PlaceholderFragment{b2d5b138 #0 id=0x7f05003c}

Wie sieht denn dein Code dazu aus.
Seht sehr nach einer fehlenen Resource ID aus.

LG Pascal //It's not a bug, it's a feature. :) ;)

Antworten
  • Forum-Beiträge: 4

22.06.2014, 18:20:20 via Website

Es kommt mir so vor als würde ich etwas klitzekleines übersehen. Ich denke hier zeigt es sich das ich nur hobbymäßig lerne :(

Also das hier ist mein fragment_main Code:

<LinearLayout 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:orientation="horizontal"
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="com.example.myfirstapp.MainActivity$PlaceholderFragment" >



<EditText android:id="@+id/edit_message"
    android:layout_weight="1"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:hint="@string/edit_message" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_send" 
    android:onClick="sendMessage" />

</LinearLayout>

und meine MainActivity :

package com.example.myfirstapp;

//verschiedene imports
public class MainActivity extends ActionBarActivity
{

public final static String EXTRA_MESSAGE = &quot;com.example.myfirstapp.MESSAGE&quot;;

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

    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container, new PlaceholderFragment())
                .commit();
    }
}


@Override
public boolean onCreateOptionsMenu(Menu menu) 
{

    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) 
{
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) 
    {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

/**
 * A placeholder fragment containing a simple view.
 */
public static class PlaceholderFragment extends Fragment 
{

    public PlaceholderFragment() 
    {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_main, container, false);
        return rootView;
    }
}
public void sendMessage(View view) 
{
    Intent intent = new Intent(this, DisplayMessageActivity.class);
    EditText editText = (EditText) findViewById(R.id.edit_message);
    String message = editText.getText().toString();
    intent.putExtra(EXTRA_MESSAGE, message);
    startActivity(intent);
}

}

Antworten
Gelöschter Account
  • Forum-Beiträge: 2.640

23.06.2014, 03:51:37 via App

Der Fehler wiegt wahrscheinlich daran, dass deine View in einem Fragment ist.
Ist mir auch passiert:/

Das Fragment wirst du wahrscheinlich nicht brauchen, deshalb kopier die Views einfach ins layout der Mainactivity und lösch das Fragment, was in diesem tutorial sowieso nicht vorkommt ";)

Edit: Für Tutorials empfehle ich die diesen Kanal hier: http://m.youtube.com/user/slidenerd

Er macht wirklich ausfühliche und leicht verständliche Tutorials und beantwortet auch sehr oft fragen

— geändert am 23.06.2014, 03:58:11

Ich sammle gerne Namen in meinem Death Note.

Samsung Galaxy Note 2<3 -> Samsung Galaxy Note 3 <3

Antworten

Empfohlene Artikel