Install phpMyAdmin on Ubuntu 16.04
sudo apt-get update sudo apt-get install phpmyadmin php-mbstring php-gettext
sudo phpenmod mcrypt sudo phpenmod mbstring
sudo systemctl restart apache2
https://domain_name_or_IP/phpmyadmin
Daily Notes of a Programmer
sudo apt-get update sudo apt-get install phpmyadmin php-mbstring php-gettext
sudo phpenmod mcrypt sudo phpenmod mbstring
sudo systemctl restart apache2
https://domain_name_or_IP/phpmyadmin
@Entity public class Troop { @OneToMany(mappedBy="troop") public Set<Soldier> getSoldiers() { ... } @Entity public class Soldier { @ManyToOne() @JoinColumn(name="troop_fk") public Troop getTroop() { ... }
References
https://stackoverflow.com/questions/11938253/jpa-joincolumn-vs-mappedby
https://stackoverflow.com/questions/37047938/jpa-hibernate-onetoone-joincolumn-referencedcolumnname-ignored
AndroidManifest.xml
<activity android:name=".ProfileActivity"> <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".MainActivity"/> </activity>
ProfileActivity.java
public class ProfileActivity extends AppCompatActivity { Toolbar toolbarProfile; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_profile); toolbarProfile = (Toolbar) findViewById(R.id.toolbarProfile); setSupportActionBar(toolbarProfile); ViewCompat.setLayoutDirection(toolbarProfile, ViewCompat.LAYOUT_DIRECTION_RTL); getSupportActionBar().setTitle(R.string.profile_management); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_back); // for custom indicator } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // Respond to the action bar's Up/Home button case android.R.id.home: NavUtils.navigateUpFromSameTask(this); //Intent intent=new Intent(ProfileActivity.this,MainActivity.class); //NavUtils.navigateUpTo(ProfileActivity.this,intent); return true; } return super.onOptionsItemSelected(item); } @Override public void onBackPressed() { NavUtils.navigateUpFromSameTask(this); super.onBackPressed(); } }
References
https://developer.android.com/training/implementing-navigation/ancestral.html
https://developer.android.com/training/implementing-navigation/temporal.html
https://stackoverflow.com/questions/28740610/how-do-i-show-back-button-in-activity
https://stackoverflow.com/questions/5312334/how-to-handle-back-button-in-activity
activity_main.xml
<android.support.design.widget.NavigationView android:id="@+id/navigationView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="end" app:menu="@menu/drawer_menu" app:headerLayout="@layout/drawer_header"> </android.support.design.widget.NavigationView>
drawer_header.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <Spinner android:id="@+id/spinnerProfile" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_gravity="center" android:layout_marginEnd="20dp" android:layout_marginLeft="10dp" android:layout_marginRight="20dp" android:layout_marginStart="10dp" android:layout_marginTop="30dp" android:layout_marginBottom="-20dp" android:gravity="center" /> </RelativeLayout>
MainActivity.java
View headerView= navigationView.getHeaderView(0); spinnerProfile= (Spinner) headerView.findViewById(R.id.spinnerProfile);
References
http://www.technotalkative.com/part-4-playing-with-navigationview/
Step 1. Please add item in menu.xml
<item android:id="@+id/navigation_drawer_item3" android:icon="@android:drawable/ic_menu_share" android:title="" app:actionLayout="@layout/spinner"/>
Step 2. Please create layout for spinner view
<Spinner xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/spinner" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_vertical" android:gravity="center_vertical" />
Step 3. set spinner data in your activity file
Spinner spinner = (Spinner) navigationView.getMenu().findItem(R.id.navigation_drawer_item3).getActionView(); spinner.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item,language)); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Toast.makeText(MainActivity.this,language[position],Toast.LENGTH_SHORT).show(); } @Override public void onNothingSelected(AdapterView<?> parent) { } });
Step 4. please add android support design library into project if need.
References
https://github.com/mhdr/AndroidSamples/tree/master/092
https://stackoverflow.com/questions/37696653/how-to-add-spinner-as-an-item-in-navigation-drawer
https://stackoverflow.com/questions/34847464/how-to-add-spinner-on-navigationview
List<String> list = ..; String[] array = list.toArray(new String[0]);
For example:
List<String> list = new ArrayList<String>(); //add some stuff list.add("android"); list.add("apple"); String[] stringArray = list.toArray(new String[0]);
References
https://stackoverflow.com/questions/4042434/converting-arrayliststring-to-string-in-java
// The original array var array = ["one", "two", "four"]; // splice(position, numberOfItemsToRemove, item) array.splice(2, 0, "three"); array; // ["one", "two", "three", "four"]
Array.prototype.insert = function (index, item) { this.splice(index, 0, item); };
References
https://davidwalsh.name/array-insert-index
NavigationView.OnNavigationItemSelectedListener navigationView_OnNavigationItemSelectedListener = new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { // uncheck other menus and sub menus int menuSize = navigationView.getMenu().size(); for (int i = 0; i < menuSize; i++) { MenuItem menuItem = navigationView.getMenu().getItem(i); if (menuItem.hasSubMenu()) { int submenuSize = menuItem.getSubMenu().size(); for (int j = 0; j < submenuSize; j++) { MenuItem subItem = menuItem.getSubMenu().getItem(j); subItem.setChecked(false); } } else { menuItem.setChecked(false); } } item.setChecked(true); if (item.getItemId() == R.id.itemMenuExit) { finish(); System.exit(0); return true; } return false; } };
References
https://github.com/mhdr/AndroidSamples/tree/master/091
btn1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub finish(); System.exit(0); } });
References
https://stackoverflow.com/questions/6014028/closing-application-with-exit-button
navigationView= (NavigationView) findViewById(R.id.navigationView); ViewCompat.setLayoutDirection(navigationView,ViewCompat.LAYOUT_DIRECTION_RTL);
Or
<android.support.design.widget.NavigationView android:layoutDirection="rtl" android:id="@+id/navigation_view" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="right" android:fitsSystemWindows="true" app:headerLayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer" />
References
https://stackoverflow.com/questions/38848821/android-right-to-left-navigationdrawer-menu-items-arent-rtl
https://github.com/mhdr/AndroidSamples/tree/master/090