Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid , unfortunately app has stopped
    primarykey
    data
    text
    <p>I am new to the android working environment, was following some tutorial regarding fragments, there appears to be no error when i build and run the project but once the app is installed on the emulator i get this message in the dialog saying the app has stopped working</p> <p>I have spent an entire day looking for a solution now any help will be appreciated here is the source code below: MainActivity.java:</p> <pre><code>package com.example.fragmentsanotherexample; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.view.Menu; public class MainActivity extends FragmentActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FragmentManager fm=getSupportFragmentManager(); android.support.v4.app.Fragment fragment=fm.findFragmentById(R.id.fragment_content); if(fragment==null){ FragmentTransaction ft=fm.beginTransaction(); ft.add(R.id.fragment_content, new BasicFragment()); ft.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; } } </code></pre> <p>BasicFragment.java:</p> <pre><code>package com.example.fragmentsanotherexample; import android.app.Activity; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.Button; import android.widget.Toast; public class BasicFragment extends Fragment{ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){ View view=inflater.inflate(R.layout.basic_fragment,container,false); Button button=(Button) view.findViewById(R.id.fragment_button); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Activity activity=getActivity(); if(activity != null){ Toast.makeText(activity, R.string.hello_world, Toast.LENGTH_LONG).show(); } } }); return view; } } </code></pre> <p>Here is the basic_fragment.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;Button android:id="@+id/fragment_button" android:text="@string/btn_fragment" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Here is activiy_main.xml:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" &gt; &lt;FragmentLayout android:id="@+id/fragment_content" android:layout_width="fill_parent" android:layout_height="fill_parent" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Here is the manifest file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.fragmentsanotherexample" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.fragmentsanotherexample.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>As far as the logcat is concerned it's empty, any sort of help would be really appreciated</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload