This is the code
This the main activity code
public class MainActivity extends AppCompatActivity implements
NavigationView.OnNavigationItemSelectedListener {
private SessionManager session;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final SharedPreferences preferences =
PreferenceManager.getDefaultSharedPreferences(this);
session = new SessionManager(getApplicationContext());
session.checkLogin();
HomeFragment home = new HomeFragment();
getSupportFragmentManager().beginTransaction().add(R.id.content,
home).commit();
FloatingActionButton fab = (FloatingActionButton)
findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(),
LoginActivity.class);
startActivity(intent);
}
});
DrawerLayout drawer = (DrawerLayout)
findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open,
R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView)
findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout)
findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
return id == R.id.action_settings ||
super.onOptionsItemSelected(item);
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
Fragment fragment = null;
Class fragmentClass = null;
int id = item.getItemId();
if (id == R.id.nav_home) {
fragmentClass = HomeFragment.class;
} else if (id == R.id.nav_req) {
} else if (id == R.id.nav_ver) {
} else if (id == R.id.nav_atividades) {
fragmentClass = AtividadesFragment.class;
} else if (id == R.id.nav_training) {
fragmentClass = TrainingFragment.class;
} else if (id == R.id.nav_settings) {
fragmentClass = SettingsFragment.class;
}
else if (id == R.id.nav_about) {
}
else if (id == R.id.nav_sair) {
session.logOut();
System.exit(0);
}
try{
assert fragmentClass != null;
fragment = (Fragment) fragmentClass.newInstance();
}catch (Exception e) {
e.printStackTrace();
}
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content,
fragment).commit();
fragmentManager.popBackStack();
DrawerLayout drawer = (DrawerLayout)
findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
}
And all fragments are ok....but when i call SettingsFragment i have this
problem
This settings call the layout like this
public class SettingsFragment extends PreferenceFragmentCompat {
// SharedPreferences sharedPreferences;
@Override
public void onCreatePreferences(Bundle bundle, String s) {
addPreferencesFromResource(R.xml.prefs);
// sharedPreferences =
PreferenceManager.getDefaultSharedPreferences(getActivity());
}
}
The rest of the fragments like this
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
savedInstanceState) {
View rootView = inflater.inflate(R.layout.atividades, container, false);
setHasOptionsMenu(true);
return rootView;
}
What's wrong?
Thanks for your help
On Thursday, February 25, 2016 at 6:29:57 PM UTC, TreKing wrote:
>
>
> On Wed, Feb 24, 2016 at 7:58 AM, Gil Carvalho <[email protected]
> <javascript:>> wrote:
>
>> So, when i runn the app in my phone...i get preferences overlaping the
>> navigation drawer...but in android studio preview it doesn't,
>>
>> Any help?
>>
>
> Show the code you use to add the layouts to your activity.
>
>
> -------------------------------------------------------------------------------------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices
>
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/6934b2b9-9805-48ba-86f5-45e3b927524e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.