I could do two different NavDrawers in the same Android App? - java

my problem is that:
I want to make a login service in my application and depending on which user logs in, go to a different NavDrawer activity. In Android Studio when you create the NavDrawer activity that comes by default, it generates one perfectly. But when I want to generate a different one, having the same name doesn't create anything.
The only way I have found is by refactoring everything generated by the Android Studio wizard and changing all the names of the layouts.
I would like to know if there is an easier way to create another NavDrawer without having to refactor so much and without so many errors.
Thank you!
NavDrawers Generated
Conceptual Scheme

Its Solved, you only need to make an instance of one of these nav drawers and then extend that to another one.

Related

Android, Java: Is it possible to have multiple layouts on a drag-able list?

I have multiple classes with different layouts which I call them Widgets in my app (this is a whole different thing from so called "Android Widgets"). I want to put instances of these classes beside each other in an activity called Dashboard. So users can change the place and settings of these widgets inside the dashboard and etc... .
I tried to use DragListView library, but the problem is each list mush have one layout AFAIK.
Any suggestions?

Creating setup wizard on Android App

In my application I need to ask the user some information in the beginning. Like Google asks users when they first launch the phone.
Using Java and Android, how do I make the same kind of setup wizard for my application? I could create multiple activities and when moving to the next page in the wizard I'd launch that. That doesn't seem a good way to do it.
I'd like to use Eclipse's GUI builder to design it.
Like This Image
create one activity for the setup wizard, and you change the content with fragments, or you open the setup wizard activity again with intent (close the existing one) and you pass some parameters, based on those parameters you show different content or you could use this https://github.com/romannurik/android-wizardpager

Why is there a loading spinner in my action bar and how do I remove it?

Basically I'm pretty new to android development but so far I've been able to fix every issue/bug I've had except this one (I've seen way worse, but for some reason this little bug takes all my time..).
Just for contact, I'm doing an application that loads local and external xml file and displays the content, fetch xml files from a server and save them locally, etc.
The issue I'm running into is the following; on older android phones (on 4.4 there is no issue, on 4.0 there is) when the application loads, I have a loading spinner icon in my action bar while the only place I use one is in another layout that is not referenced in my main activity. I figured maybe it's because I didn't initiate my menu correctly or something, but everything seems fine (and works on newer versions). I have a searchview that is working fine, a settings menu that is also fine, but for some reason there is always a spinning icon next to those elements.
I can edit this and add my layout/code if needed.
Thanks!
maybe put setProgressBarIndeterminateVisibility(false) in Activitys onCreate (check docs)

Eclipse Android SDK: Can't access layouts after adding 2nd activity

I'm very new to Android and Java developing. So far, everything worked pretty well. But i keep failing adding a 2nd activity and accessing its layout elements.
I used the manifest.xml wizard and file->new->other->android activity. This works well, adds a new java file and layout. Starting the activity works also pretty well.
My problem is that i can't access any elements of the new layout. When i try to create a button via "findViewById(R.id.?)" it shows elements that don't exist on the layout, but the elements on my layout are not shown. It seems that a layout from a previous project is used.
Additionaly the eclipse editor shows a warnining in a line above:
setContentView(R.layout.activity_secondactivity);
"activity_secondactivity cannot be resolved or is not a field".
This warning is not there until i type "R.id." and even if i delete it, it won't disappear.
In all tutorials on the web and youtube it seems to work so fine, i was trying different things for two days and can't figure it out. I would be very happy if anyone could help me out :)
Make sure you imported the right "R" (yourpackage.R) and not android.R. For example, if your package name is com.my.package, then you have to import com.my.package.R. And try clean your project (Project->Clean).

Can The Application Icon in the Built In Search Dialog Be Clickable?

Is there anyway to capture when the user clicks on the application icon in the built in search dialog? Please note I am NOT referring to a custom dialog but to android built in search dialog.
Nope, there is no way to make the SearchDialog's app icon clickable.
But just for fun, let's assume there existed some hacky workaround that would get the job done. Cool, we have got the desired behavior... but now we have two issues:
The behavior of the SearchDialog is not consistent with other Android devices. This lessens the user experience since users expect search interfaces to work the same on all Android devices.
Your app now makes use of the internal APIs, which may or may not remain consistent when new SDKs are released. For all you know, the Android team could change the app icon's id from #+id/search_app_icon to #+id/search_home_icon. Your hack depends on the internal APIs... so such a change will cause newer devices running your app to crash (as any runtime search for search_app_icon will return null).
Further, companies like Samsung and HTC are free to alter the internal APIs before they release their new devices to the public. The next Samsung Galaxy could potentially completely re-implement the SearchDialog class, update its UI/theme, etc... you can never know for sure.
So basically, you can't... and you shouldn't make an attempt to do so.
Just because I'm bored, here's the source code that led me to my answer:
Check out the source code for SearchManager.java, and notice that the SearchManager keeps the SearchDialog as a private instance variable mSearchDialog.
Check out the source code for SearchDialog.java, and notice that the SearchDialog references the app icon as the private instance variable mAppIcon. Also notice that the SearchDialog initializes the variable through a call to findViewById, as seen here.
Check out the source code for search_bar.xml and notice that the ImageView is not set to clickable by default. Since there are no (methods in the public SDK that alter the behavior of this View, there is no reliable way to make it clickable.
I'm sure it's impossible to do this using the Android's public SDK.
I think the only solution is write your own custom dialog, but I'm affraid that with the built in dialog you can't accomplish this.

Categories

Resources