Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is how i do it :</p> <pre><code>import android.content.Intent; import android.os.Bundle; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.util.Log; import android.widget.Button; import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuItem; public class MainPoP extends SherlockFragmentActivity implements ListFragment.OnMainMenuListener{ Button home; Button about; Button donate; Button explore; ActionBar actionbar; ListFragment mainMenu; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); mainMenu = new ListFragment(); ft.add(R.id.mainView, mainMenu).addToBackStack(null).commit(); } } </code></pre> <p>THis is how i am making a fragment and its working just fine. Try using the OnCreateView method to inflate your fragment like this in the class which is extending Fragment or is the particular fragment which you want to set some layout:</p> <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.about_fragment, container, false); return v; } </code></pre>
 

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