listfragment overlapping my main drawer

Course Queries Syllabus Queries 3 years ago

5.45K 2 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 years ago


im new in android im creating an app and i have a problem with a listfragment, because the list its showing but its overlapping the title bar(i had to add margin top to change that), and also im using a drawer and when im trying to open the list it shows over the options drawer too, letme paste you the code and the image so you can understan more:

The xml code:

    xml version="1.0" encoding="utf-8"?>
 xmlns:android="http://schemas.android.com/apk/res/android"
    android:https://forum.tuteehub.com/tag/orientation">orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="1">

    
        android:layout_width="match_parent"
        android:layout_height="420dp"
        android:id="@android:id/https://forum.tuteehub.com/tag/list">list"
        android:layout_weight="0.82"
        android:layout_marginTop="60dp" />

The https://forum.tuteehub.com/tag/list">listFregment code:

  public class FragmentoPrincipalChofer extends ListFragment {
    private List<ParseObject> mViaje;
    private ListView mLista;

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {



        View x = inflater.inflate(R.layout.fragmento_principal_chofer, container, false);
        mLista = (ListView)x.findViewById(android.R.id.https://forum.tuteehub.com/tag/list">list);
        return x;

    }

    @Override
    public void onResume() {
        super.onResume();

        //obtener pedido de taxi
       ParseQuery<ParseObject> query = ParseQuery.getQuery("Viaje");
        query.whereEqualTo("chofer", "prueba3");
        query.addDescendingOrder("createdAt");
        query.findInBackground(new FindCallback<ParseObject>() {
            public void done(List<ParseObject> viajes, com.parse.ParseException e) {
                if (e == null) {
                    mViaje=viajes;
                    String[] nombreUsuarios = new String[mViaje.size()];
                    int i=0;
                    for (ParseObject viaje : mViaje){

                        nombreUsuarios[i] = viaje.getString("cliente");
                        i++;
                    
                                                
0 views
0 shares

profilepic.png
manpreet 3 years ago

your problem is your setting your list fragment to the whole view Id with this line

// android.R.id.content is the WHOLE screen of your Activity
transaction.add(android.R.id.content,fragmento,"fragmento");
transaction.commit();

Create a FrameLayout in your content_drawer_principal.xml:

 android:id="@+id/list_content"
       android:layout_width="match_parent"
       android:layout_height="match_parent"/>

then do:

transaction.add(R.id.list_content,fragmento,"fragmento");
transaction.commit();

UPDATE

The real problem here is that your telling your FragmentTransaction to load your FragmentoPrincipalChofer into android.R.id.content which is a reserved id

android.R.id.content gives you the root element of a view, without having to know its actual name/type/ID.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Similar Forum