Comments (16)
Do you call the notifyDatasetChanged on the adapter ?
2013/11/20 TheoTzaferis [email protected]
Hey,
I have used your Navigation Drawer and its really awesome. The best one
I've used. I modified it a bit so I can have my own backgroundcolor and
don't have to use an image. I added a method, that has the name
createColor and gets a color as an additional paramter to the create
-method.What I have are 3 sections. The user is able to select one item from each
section and the fragment gets changed dependent on the user selection. This
works without any problems. The filtering works perfectly fine.The only thing I want to do know is to highlight the selections by also
giving them a blue background. But the problem is that only the settings
that I've defined at the beginning are the ones that get blueThis is my Config
@OverRide
protected NavDrawerActivityConfiguration getNavDrawerConfiguration() {
NavMenuSection topCharts;
NavMenuSection sources;
NavMenuSection sort;
NavMenuSection links;NavMenuItem today; NavMenuItem week; NavMenuItem month; NavMenuItem year; NavMenuItem allBlogs; NavMenuItem onlyBlogs; NavMenuItem allNetworks; NavMenuItem facebook; NavMenuItem twitter; NavMenuItem google; NavMenuItem fliesBlog; NavMenuItem feedback; NavMenuItem impress; topCharts = NavMenuSection.create(100, "Top-Charts" ); sources = NavMenuSection.create(200, "Quellen" ); sort = NavMenuSection.create(300, "Sortierung" ); links = NavMenuSection.create(400, "Links" ); Log.v ( "getNavdrawerConfiguration" , "timefilter: " + this.getTimefilter() ); Log.v ( "getNavdrawerConfiguration" , "blogfilter: " + this.getBlogfilter() ); Log.v ( "getNavdrawerConfiguration" , "socialfilter: " + this.getSocialfilter() ); if ( this.getTimefilter() == null || this.getTimefilter().equals ( "main" ) ){ today = NavMenuItem.createColor (101, "Heute" , false, this, getResources().getColor(R.color.actionBarOwn)); week = NavMenuItem.create (102, "Woche" , false, this); month = NavMenuItem.create (103, "Monat" , false, this); year = NavMenuItem.create (104, "Jahr" , false, this); } else if ( this.getTimefilter().equals ( "week" ) ){ today = NavMenuItem.create (101, "Heute" , false, this); week = NavMenuItem.createColor (102, "Woche" , false, this, getResources().getColor(R.color.actionBarOwn)); month = NavMenuItem.create (103, "Monat" , false, this); year = NavMenuItem.create (104, "Jahr" , false, this); } else if ( this.getTimefilter().equals ( "month" ) ){ today = NavMenuItem.create (101, "Heute" , false, this); week = NavMenuItem.create (102, "Woche" , false, this); month = NavMenuItem.createColor (103, "Monat" , false, this, getResources().getColor(R.color.actionBarOwn)); year = NavMenuItem.create (104, "Jahr" , false, this); } else { today = NavMenuItem.create (101, "Heute" , false, this); week = NavMenuItem.create (102, "Woche" , false, this); month = NavMenuItem.create (103, "Monat" , false, this); year = NavMenuItem.createColor (104, "Jahr" , false, this, getResources().getColor(R.color.actionBarOwn)); } if ( this.getBlogfilter() == null || this.getBlogfilter().equals ( "main" ) ){ allBlogs = NavMenuItem.createColor (201, "Alle Quellen" , false, this, getResources().getColor(R.color.actionBarOwn)); onlyBlogs = NavMenuItem.create (202, "Nur Blogs" , false, this); } else { allBlogs = NavMenuItem.create (201, "Alle Quellen" , false, this); onlyBlogs = NavMenuItem.createColor (202, "Nur Blogs" , false, this, getResources().getColor(R.color.actionBarOwn)); } if ( this.getSocialfilter() == null || this.getSocialfilter().equals ( "main" ) ){ allNetworks = NavMenuItem.createColor (301, "Alle Netzwerke" , false, this, getResources().getColor(R.color.actionBarOwn)); facebook = NavMenuItem.create (302, "Facebook" , false, this); twitter = NavMenuItem.create (303, "Twitter" , false, this); google = NavMenuItem.create (304, "Google+" , false, this); } else if ( this.getSocialfilter().equals ( "facebook" ) ){ allNetworks = NavMenuItem.create (301, "Alle Netzwerke" , false, this); facebook = NavMenuItem.createColor (302, "Facebook" , false, this, getResources().getColor(R.color.actionBarOwn)); twitter = NavMenuItem.create (303, "Twitter" , false, this); google = NavMenuItem.create (304, "Google+" , false, this); } else if ( this.getSocialfilter().equals ( "twitter" ) ){ allNetworks = NavMenuItem.create (301, "Alle Netzwerke" , false, this); facebook = NavMenuItem.create (302, "Facebook" , false, this); twitter = NavMenuItem.createColor (303, "Twitter" , false, this, getResources().getColor(R.color.actionBarOwn)); google = NavMenuItem.create (304, "Google+" , false, this); } else { allNetworks = NavMenuItem.create (301, "Alle Netzwerke" , false, this); facebook = NavMenuItem.create (302, "Facebook" , false, this); twitter = NavMenuItem.create (303, "Twitter" , false, this); google = NavMenuItem.createColor (304, "Google+" , false, this, getResources().getColor(R.color.actionBarOwn)); } fliesBlog = NavMenuItem.create(401, "10000 Flies Blog", false, this); feedback = NavMenuItem.create(402, "Feedback" , false, this); impress = NavMenuItem.create(403, "Impressum" , false, this); NavDrawerItem[] menu = new NavDrawerItem[] { topCharts, today, week, month, year, sources, allBlogs, onlyBlogs, sort, allNetworks, facebook, twitter, google, links, fliesBlog, feedback, impress, }; NavDrawerActivityConfiguration navDrawerActivityConfiguration = new NavDrawerActivityConfiguration(); navDrawerActivityConfiguration.setMainLayout(R.layout.activity_main); navDrawerActivityConfiguration.setDrawerLayoutId(R.id.drawer_layout); navDrawerActivityConfiguration.setLeftDrawerId(R.id.left_drawer); navDrawerActivityConfiguration.setNavItems(menu); navDrawerActivityConfiguration .setDrawerShadow(R.drawable.drawer_shadow); navDrawerActivityConfiguration.setDrawerOpenDesc(R.string.open_drawer); navDrawerActivityConfiguration.setDrawerCloseDesc(R.string.mainTitle); navDrawerActivityConfiguration.setBaseAdapter(new NavDrawerAdapter( this, R.layout.navdrawer_item, menu)); return navDrawerActivityConfiguration;
}
As you can see, when a certain filter is set the Navigation Menu should
change. The logcat, also tells me the set timefilter, socialfilter and
blogfilter. So that would mean, that the app always comes again into the
NavigationDrawreConfiguration but doesn't set it.I tried so many things like invalidateOptionsmenu and clear the adapter.
But none of them worked. I would be really happy if you could tell me how
exactly I can do that!�
Reply to this email directly or view it on GitHubhttps://github.com//issues/1
.
from yourappidea.
Hey. Yes I tried that. Maybe it was just the different place, where I did it? The things I've done were to create a
NavDrawerAdapter navDrawerAdapter;
And then, in the onNavItemSelected
I set navDrawerAdapter.notifyDataSetChanged
- Is it the wrong place? I have a MainActivity
where the navigationconfiguration is locted and a fragment where the whole data gets displayed. Where exactly do I have to set that? When I do it as I said either nothing happens or a NullPointerException
is thrown. And it is for this line
this.onNavItemSelected(selectedItem.getId());
in AbstractNavDrawerActivity.java
from yourappidea.
Hey. I'm still stuck to this problem. I'll try to make it more clear. The MainActivity.class
has the method getNavDrawerConfiguration
where I assign the menu items and sections to a NavDrawerItem object and then configurate it like in your example.
In the MainActivity there is also the method onNavItemSelected
Dependend on the case I open up a fragment. Now, when a fragment gets opened I set the options dependent on the click. This works without problems. The fragment gets replaced into a FrameLayout
from the activity_main.xml
like that: ft.replace(R.id.content_frame, new MainFragment());
After it has changed I would like to refresh the NavDrawer
What I tried was to create a new Adapter.
NavDrawerAdapter navDrawerAdapter
and then, after the commit, calling navDrawerAdapter.notifyDataSetChanged()
but that line crashes the app with a NullPointerException
- When I try to initialize the variable I have to give a context, textViewReference and the objects I want to pass. But the objects I want to pass are only created in the getNavDrawerConfiguration
. So I can't assign them.
I hope this is detailed enough, because this is the last part of the app I need to finish my app!
from yourappidea.
Hi,
Is it possible for you to send the source code of your project ?
2013/11/21 TheoTzaferis [email protected]
Hey. I'm still stuck to this problem. I'll try to make it more clear. The
MainActivity.class has the method getNavDrawerConfiguration where I
assign the menu items and sections to a NavDrawerItem object and then
configurate it like in your example.In the MainActivity there is also the method onNavItemSelected Dependend
on the case I open up a fragment. Now, when a fragment gets opened I set
the options dependent on the click. This works without problems. The
fragment gets replaced into a FrameLayout from the activity_main.xml like
that: ft.replace(R.id.content_frame, new MainFragment()); After it has
changed I would like to refresh the NavDrawerWhat I tried was to create a new Adapter.
NavDrawerAdapter navDrawerAdapter
and then, after the commit, calling
navDrawerAdapter.notifyDataSetChanged() but that line crashes the app
with a NullPointerException - When I try to initialize the variable I
have to give a context, textViewReference and the objects I want to pass.
But the objects I want to pass are only created in the
getNavDrawerConfiguration. So I can't assign them.I hope this is detailed enough, because this is the last part of the app I
need to finish my app!—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-28965695
.
from yourappidea.
Hi,
I'm unfortunate that it is in fact not. It's a project for a customer. The only thing I could send you would be the MainActivity
and the classes I got from you. Would that be enough? I don't think you would need the fragments, would you? The MainActivity
is anyway the only class where I'm doing the logic of the Navigation Drawer. The fragments aren't affected by that.
from yourappidea.
And could you create a simple project with the minimal code to reproduce
the issue ?
2013/11/21 TheoTzaferis [email protected]
Hi,
I'm unfortunate that it is in fact not. It's a project for a customer. The
only thing I could send you would be the MainActivity and the classes I
got from you. Would that be enough? I don't think you would need the
fragments, would you?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-28965978
.
from yourappidea.
Basically yes. Give me some minutes, I will do that right now.
from yourappidea.
https://mega.co.nz/#!DVEETIJa!SgS0e2HdMzLpd1NhF7XiCkAI-qsgI7nWmpYyYVQq-kY
Here you go. When you now click on Week I want that Week gets the background and not today!
from yourappidea.
I'm at work now, i will try this evening.
2013/11/21 TheoTzaferis [email protected]
https://mega.co.nz/#!DVEETIJa!SgS0e2HdMzLpd1NhF7XiCkAI-qsgI7nWmpYyYVQq-kY
Here you go. When you now click on Week I want that Week gets the
background and not today!—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-28967489
.
from yourappidea.
Thanks in advance. It would be awesome if you could help me! This is the last thing I need for the app
from yourappidea.
Look at this.
But i think this is not the best way.
You should use t the attribute ?activatedBackgroundIndicator to change the
color of the selected item of the list.
best regards
Laurent
2013/11/21 TheoTzaferis [email protected]
Thanks in advance. It would be awesome if you could help me! This is the
last thing I need for the app—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-28970306
.
from yourappidea.
Hey. Did you forget to attatch something? Because i cant see anything except your text.
Yeah the avtivatedBackgroundIndicator only works for one item doesnt it? I need it for multiple dependent on the click. Max 3 at once and only 1 per section
from yourappidea.
sorry.
2013/11/21 TheoTzaferis [email protected]
Hey. Did you forget to attatch something? Because i cant see anything
except your text.
Yeah the avtivatedBackgroundIndicator only works for one item doesnt it? I
need it for multiple dependent on the click. Max 3 at once and only 1 per
section—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-29029743
.
from yourappidea.
No problem. :) But I still can't see anything except your texts
from yourappidea.
http://www.michenux.net/download/TestHelp1.zip
This is not the best solution because i recreate the adapter each time.
I recreate it because it is an ArrayAdapter and you can't modify it (clear
and add elements).
It would be best to write an Adapter owning a List, instantiate it once
only, and when needed, modify the data inside, and call its method
notifyDataSetChanged().
2013/11/22 TheoTzaferis [email protected]
No problem. :) But I still can't see anything except your texts
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-29052833
.
from yourappidea.
A thousand thanks! I will use this for my first release and then, in the second release try to use an Adapter owning a List!
from yourappidea.
Related Issues (16)
- cannot find symbol variable PACKAGE_NAME HOT 3
- JDK Error HOT 8
- Social Autentication session
- How to start a user session.
- friend list (recycle view) not scrolling HOT 2
- GSON throwing Expected BEGIN_OBJECT but was BEGIN_ARRAY HOT 2
- Switching between Android Navigation Drawer image and Up caret when using fragments
- AbstractContentProvider.java:40 (com.android.tools.fd.runtime.BootstrapApplication cannot be cast to org.michenux.drodrolib.MCXApplication) HOT 3
- Add navigation drawer in other activities along with main activity
- FATAL EXCEPTION HOT 2
- Error project HOT 2
- Simple Map HOT 1
- Fix .gitignore HOT 1
- which one is the google store app?
- what happen after "?listPreferredItemHeightSmall" fixed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yourappidea.