Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

listfragment overlapping my main drawer

Course Queries Syllabus Queries
Max. 2000 characters
Replies

usr_profile.png
Brian Burl

User

( 4 months 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"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="1">

    <ListView
        android:layout_width="match_parent"
        android:layout_height="420dp"
        android:id="@android:id/list"
        android:layout_weight="0.82"
        android:layout_marginTop="60dp" />
</LinearLayout>

The 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.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++;
                    
								 								 
							usr_profile.png
							
Rahul Chaudhary

User

( 4 months 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:

<FrameLayout 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.

what's your interest