how to access footer from all activities in android application - android

i have footer layout contains 4 button. footer display in all my activities like
now i have 2 questions:
as image shows when click on any button then color of button image and the background will be change
how to access footer button from activities,i don't want to do copy paste the same code in all activities.is there another way to do this.
how to do this 2 things

For 1.
to change the color of the icon:
buttonView.setColorFilter(ContextCompat.getColor(YourActivity.this, R.color.yourColor1));
to change the background color:
buttonView.setBackgroundTint(ContextCompat.getColor(YourActivity.this, R.color.yourColor2));
For 2:
You could implement a basic Activity, where you put your code to handle the footer access. Then you derive all your activities from that basic activity
If you need further instructions for 2. write comment

Related

Navigation drawer in Android

I know it should be in the style sheet area for this, but when I created a new Android app using Android Studio, it has a user logo and user information in a green box. This is what I want to edit.
First it should ask them to login if first time using the app.
But let's deal with one thing at a time, and first is me getting use to where Google puts things.
If you look at your layout activiy you will find a "NavigationView", there are 2 attributes there you need "header" and "menu".
You can see in this answer how.to get the views inside the "header" file: https://stackoverflow.com/a/33631797/4017501
There is another alternative. The "NavigationView" is a ViewGroup. So you can use it as such. Delete thee "header" and "menu" attribute and add the closing brackets as if were a ViewGroup:
<NavigationView></NavigationView>
Now you can simply put a fragment inside and then find every view and handle your logic from the fragment, is a more direct and customizable approach.

File browser with a ListView and back button

I am working on a simple file explorer using android os.
I get the whole directory structure like filesize, filenames, directory name via a json object and put them in a list view. On 1) you can see, what I finally want to do.
The problem is, that the items have a complete other style like the back botton, so I may have to deal with two list views (one for the back button in every sub directory and one for the items like the 2nd variant in my picture). But having two listviews, the first one should resize in the root directory, so that it fits in the height like the version with a back button.
Do you have any ideas? I hope you unterstand, want I want.
1]: http://www.basepic.com/2014/Mar/13/97965279.png
WOuldn't it be better if you just add a button with the visibility GONE. And only make it visible on the top if you want to show the back button else just leave it hidden? Why a seperate listview for just one button?

Navigation buttons in header xml

I'm working on my first android app and have been trying to make a header consisting of three image buttons for back, home, and next. I was wondering if it's possible to make the header in a separate XML file, and then use include so that I may cut down on redundancy and reuse the header with multiple activities. I've been able to do this so that the navigation buttons display, but have not found a way to make the buttons navigate between activities. Thanks!
You can use an intent to navigate across activities on button pressed. First, in the xml drag and drop a button. Then initialize this button in your activity.
Eg.
Button BackBtn=(Button) findViewById(R.id.button1);
Once you have got reference to the button you can set onclick listener to this button and onclick of it, you can use to below code to navigate across activities.
Intent i =new Intent();
i.setClass(fromClass,ToClass.class);
startActivity(i);
I hope the above code would have helped.
Regarding the second part of the question, although you can define a seperate xml containing 3 buttons for navigation, you need to redefine its functionality in every activity you use them in. So instead i suggest you to create a sub-layout inside your current layout and in that add three buttons. From next activity onwards, you can copy paste that layout in your new xml.

Creating a custom TAB

I want to create a TAB-like activity.
The regular tab host has a specific design.
I want the tab buttons to be image views without any BG.
And by clicking on the image will just change the tab the regular way?
Maybe there is a way to do it in the regular TAB host?
I will be more specfici - the 2 buttons are actually 2 image views (also has 1 png for selected and 1 png for unselected). These 2 images are on the main BG (unlike the UI of the TAB Host). Upper to them there is the area (e.g. Frame) where my 2 activites should be ... Both activities has listview in it.
Check these:
Custom Android Tabs
Customize Android TabHost TabWidget
yes . you can do it . create yourView.xml and set this to TabSpec.setIndicator(View)
A simple solution will be to create 2 separate views for the 2 tabs, then depending on which button (Tab1 or Tab2) is clicked, make the corresponding view visible and the other gone.
And of course you can give whatever background image to the buttons you want.

android custom button

I need to create some custom buttons as shown in the image below
what is the best approach to follow?
thanks
Abdul Khaliq
That's a hard one. I made a lot of custom views, and the first thing I would thinking of is, made one Button with that above image, and handle onTouch by yourself so you can distinguish which area the user hit. There you can also change the state of the button, like changing the image to a bevel one e.g. when the left button is hit.
Can you imagine this ansatz?
You can place two transparent "invisible" buttons over the top of a background in a LinearView. Like two ImageButtons with a transparent png inside.
It is also possible to make this background animated when buttons are clicked using android animation class.

Categories

Resources