React Native

Problem with Real Device

  1. Create a new folder => android/app/src/main/assetsjust create the folder assets in “android/app/src/main/”
  2. Run this command:
    react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

    This command will create 2 files:

    1. index.android.bundle
    2. index.android.bundle.meta
  3. run command
    react-native run-android

sometime you may get the error like…but it’s ok.

shareimprove this answer

1- Create a new folder => android/app/src/main/assets
2- Run this command =>

 react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res  

This command will create 2 files : index.android.bundle & index.android.bundle.meta

3- run command => react-native run-android

Advertisements

How to access views insde the actionLayout in menu

<menu xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <group
        android:visible="true"
        android:id="@+id/menu">
        <item
            android:id="@+id/nav_dashboard"
            android:icon="@drawable/ic_dashboard_home"
            android:title="Dashboard" />
        <item
            android:id="@+id/nav_time_sheet"
            android:icon="@drawable/ic_time_sheet"
            android:title="Time Sheet" />
        <item
            android:id="@+id/nav_setting"
            android:icon="@drawable/ic_settings"
            android:title="Setting" />

        <item
            android:id="@+id/nav_messaging"
            android:icon="@drawable/ic_chat"
            android:title="Chat" />

        <item
            android:id="@+id/nav_syn"
            android:icon="@drawable/ic_syncronize"
            android:title="Syncronize"/>

        <item
            android:id="@+id/nav_switcher"
            android:icon="@drawable/ic_mode"
            android:title="Offline Mode"
            android:clickable="false"
            app:actionLayout="@layout/layout_switcher_button" />
    </group>
</menu>


NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
MenuItem itemMenus = navigationView.getMenu().findItem(R.id.nav_switcher);
LinearLayout tracks = (LinearLayout) itemMenus.getActionView();
Switch switcher_mode = (Switch) tracks.findViewById(R.id.nav_drawer_switch);
switcher_mode.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Log.d("Hello","Hi");
    }
});

Blog at WordPress.com.

Up ↑