I am creating an Android application that consists of a navigation box in android studio. I get an error called non-convertible types, I can not distinguish . How to solve non-convertible types cannot distinguish "Android.support.v4.app.fragment" from "packagename" " , please help solve this problem. This is my activity_main.java
package sample.lakshman.com.sampleltester; import android.content.Intent; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.support.v7.widget.Toolbar; import sample.lakshman.com.sampleltester.Fragment_navigation; public class MainActivity extends ActionBarActivity { public Toolbar toolbar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = (Toolbar) findViewById(R.id.tool_bar); setSupportActionBar(toolbar); Fragment_navigation drawer_navigation = (Fragment_navigation)getSupportFragmentManager().findFragmentById(R.id.fragment_navigation_drawer); drawer_navigation.setUp((DrawerLayout)findViewById(R.id.drawer_layout),toolbar); } @Override public boolean onCreateOptionsMenu(Menu menu) {
This is my main_activity.xml
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" > <include android:id="@+id/tool_bar" layout="@layout/tool_bar" /> </RelativeLayout> <fragment android:id="@+id/fragment_navigation_drawer" android:layout_width="250dp" android:layout_height="match_parent" android:layout_gravity="start" app:layout="@layout/fragment_fragment_navigation" android:name="sample.lakshman.com.sampleltester.Fragment_navigation" tools:layout="@layout/fragment_fragment_navigation" /> </android.support.v4.widget.DrawerLayout>
source share