В навигационном ящике нет предметов - PullRequest
0 голосов
/ 05 февраля 2019

В моем навигационном ящике ничего не отображается.Я изменил фон на белый, тема изменилась, но по-прежнему не отображаются элементы.Я также использую макет рамы внутри ящика и линейные макеты.Нет ошибок или сообщений.Что я делаю неправильно?

РЕДАКТИРОВАТЬ: Я упростил свою работу, но все равно ничего.Нет элементов ..

РЕДАКТИРОВАТЬ 2: После удаления я достиг некоторого прогресса, и теперь я вижу, что в окне предварительного просмотра моё окно_окна отображается в виде меню параметров в верхнем правом углу, хотя и в postLoginactivityПредварительный просмотр файла .xml показывает, что я стремился сделать.Все еще нет элементов на эмуляторе.

EDIT3: У меня есть Cutt мой код пополам, все еще не вижу, что я сделал не так.

activity_post_login.xml
<?xml version="1.0" encoding="utf-8"?>

<android.support.v4.widget.DrawerLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
>
<!-- burdan sonra komple sıkıntı gibi?-->
<LinearLayout
    android:id="@+id/llayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">


    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="@color/colorPrimary"
        android:elevation="4dp"
        android:theme="@style/ThemeOverlay.AppCompat.Light" >

    <TextView
        android:id="@+id/textView"
        android:layout_width="326dp"
        android:layout_height="45dp"

        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:accessibilityLiveRegion="assertive"
        android:paddingStart="100dp"
        android:paddingEnd="100dp"
        android:text="@string/deneme"
        android:textSize="30sp"
        android:visibility="visible"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    </android.support.v7.widget.Toolbar>
    <!-- android:layout_height=?attr/actionBarSize-->


    <FrameLayout
        android:id="@+id/mainFrameLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        app:layout_constraintTop_toBottomOf="parent"
        tools:layout_editor_absoluteX="0dp"/>








</LinearLayout>


<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    app:headerLayout="@layout/nav_header"
     >
<ExpandableListView
    android:id="@+id/list_sliderMenu"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:paddingTop="176dp"
    android:choiceMode="singleChoice"
    android:divider="@android:color/transparent"
    android:dividerHeight="1dp"
    />

</android.support.design.widget.NavigationView>


</android.support.v4.widget.DrawerLayout>





nav_header.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="176dp"
android:background="@color/colorPrimary"
android:gravity="bottom"
android:padding="16dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:orientation="vertical"
>

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@mipmap/ic_launcher_round"/>

</LinearLayout>




drawer_menu.xml
<?xml version="1.0" encoding="utf-8"?>

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
>
<!--tools:showIn="navigation_view"-->




<group android:checkableBehavior="single"
    android:id="@+id/menu_list">

    <item android:title="@string/satisYonetimi"
        android:id="@+id/satis_yonetimi"/>
    <item
        android:id="@+id/insanKaynaklari"

        android:title="@string/insanKaynaklari" />
    <item
        android:id="@+id/muhasebeYonetimi"

        android:title="@string/muhasebeYonetimi" />
    <item
        android:id="@+id/aktiviteYonetimi"

        android:title="@string/aktiviteYonetimi" />
    <item
        android:id="@+id/destekYonetimi"

        android:title="@string/destekYonetimi" />

</group>
</menu>





styles.xml
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar" parent="@style/AppTheme" >
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

</resources>


 v21\styles.xml
 <resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar" parent="@style/AppTheme" >
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

</resources>

Плюс, есликто-то думает, что проблема может быть где-то еще здесь: category.java (расширяемый список), subcategory.java (будущие подменю будут реализованы) и моя активность для ящика, который будет отображаться (в процессе реализации)

category.java

public class Category {
private String cat_name;
private  int cat_code;

public void setCat_name(String cat_name) {
    this.cat_name = cat_name;
}
public String getCatName(){
    return cat_name;
}

public void setCat_code(int cat_code) {
    this.cat_code = cat_code;
}

public int getCat_code() {
    return cat_code;
}
}



subcategory.java
public class SubCategory {
private String subcat_name;
private  String subcat_code;

public void setSubCatName(String subcat_name) {
    this.subcat_name = subcat_name;
}
public String getSubCatName(){
    return subcat_name;
}

public void setSubCatCode(String subcat_code) {
    this.subcat_code = subcat_code;
}

public String getSubCatCode() {
    return subcat_code;
}
}


postLogingActicity.java
import android.app.ActionBar;
import android.app.Activity;
import android.os.Bundle; 
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;  
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;

import java.util.ArrayList;


public class PostLoginActivity extends AppCompatActivity  {

ActionBar bar;
ViewPager viewPager;
FragmentPagerAdapter fpAdapter;
Fragment mMainScreen;

private DrawerLayout mDrawerLayout;
private ActionBarDrawerToggle mDrawerToggle;
private ExpandableListView mCategoryList;

private ArrayList<Category> category_name = new ArrayList<Category>();
private ArrayList <ArrayList<Category>> subcategory_name = new ArrayList 
<ArrayList<Category>>();
private ArrayList<Integer> subCatCount = new ArrayList<Integer>();

int previousGroup;

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_post_login);     

    //Toolbar toolbar =findViewById(R.id.toolbar);
    //setSupportActionBar(toolbar);

    //mDrawerLayout = findViewById(R.id.drawer_layout);

    //ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, 
 //mDrawerLayout, toolbar,
     //       R.string.navigation_drawer_open, 
//R.string.navigation_drawer_close);
    //mDrawerLayout.addDrawerListener(toggle);
    //toggle.syncState();

    //this.getCatData();
    //Utils.deleteStringFromSp(this, "email");        
}

public void onBackPressed(){
    if(mDrawerLayout.isDrawerOpen(GravityCompat.START))
        mDrawerLayout.closeDrawer(GravityCompat.START);
    else
        super.onBackPressed();

}
}

Ответы [ 2 ]

0 голосов
/ 06 февраля 2019

Вы пропустили ссылку на меню вида навигации

Так как вы назвали его "pocket_menu_xml", тогда модификация будет:

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    app:headerLayout="@layout/nav_header"
    app:menu="@menu/drawer_menu"/>
0 голосов
/ 06 февраля 2019

ваша основная активность должна выглядеть следующим образом

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="rtl"
android:fitsSystemWindows="true"
tools:openDrawer="start">



<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    app:menu="@menu/activity_main_drawer" />

   </android.support.v4.widget.DrawerLayout>

И activity_main_drawer

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="navigation_view">

<group android:checkableBehavior="single">


    <item
        android:id="@+id/nav_menu7"
        android:icon="@drawable/ic_school_black_24dp"
        android:title="XXXX" />

    <item
        android:id="@+id/nav_menu11"
        android:icon="@drawable/ic_thumb_up_black_24dp"
        android:title="XXXX" />

    <item
        android:id="@+id/nav_menu12"
        android:icon="@drawable/ic_insert_drive_file_black_24dp"
        android:title="XXXX" />

    <item
        android:id="@+id/nav_menu6"
        android:icon="@drawable/ic_developer_mode_black_24dp"
        android:title="XXXX" />
</group>

</menu>

В Kotlin Меню навигации

    // Navigate Menu
    override fun onNavigationItemSelected(item: MenuItem): Boolean {
    // Handle navigation view item clicks here.
    when (item.itemId) {



        R.id.nav_menu7 -> {


            val intent = Intent(this, Computer::class.java)
            startActivity(intent)
        }
        R.id.nav_menu6 -> {

            val menu6 = Menu6()
            val fragmentManager = supportFragmentManager
            fragmentManager.beginTransaction().replace(R.id.fragment,  menu6).addToBackStack(null).commit()
        }

        R.id.nav_menu12 -> {

            val intent = Intent(Intent.ACTION_VIEW,    Uri.parse("https://XXXXX"))
            startActivity(intent)
        }


    }
    drawer_layout.closeDrawer(GravityCompat.START)
    return true
    }

Я надеюсь, что это решит вашу проблему. Меню работает с Activity, Fragment, URL

...