How to create Custom menu and activity - java

How to create custom menu like image sample?(java-android-android studio)
Can use the library for this?!
enter image description here
I don't create this activity and menu!
I use fragment for activity but i can't create menu and activity 😔!

Related

Set an on click listener on button in a fragment in the main activity file

I have tried to do some research on the topic and I am attempting to add an on-click listener for a button in a fragment in the main activity. So when I click a button in a fragment the click can get registered in the main activity file.
You can use custom broadcast receiver
You will register a receiver on button click in fragment
Then in activity apply action if this broadcast action equal to this custom action
you can use interface for this problem

How to make classes in android-studio to use the same root layout but with different text shown on TextViews

I am a beginner and this is my first app.
I am making an app that will show the user Text View in the mainActivity.xml, ex.Music, then the user can click on the 'music' text View(via intent) , and it goes to another activity where are displayed several other text views.
ex. Rap, Pop, Rock, Punk ... each of these views can be clicked (with intent), and again it leads to another activity, where are displayed various sub-genres of let's say Rock, and the user can click on one of them and then it shows some text views with name of the songs of that genre and if clicked the final intent leads the user to the Youtube app.
The 'problem' is that I have to create new class and new activity for every genre, create text view with id in xml layout , define intent in the class with setOnClickListener and goes to another activity.
If i do this for every genre, I may need more than 200+ classes and layouts for the whole app.
Is there some way to make a one root layout xml, and just in every class use that layout but with different text in text views.
Also can i somehow reduce the number of classes needed for this ?
I tried with ArrayList<> to add the text in text views but i can't find the id so that i can call the intent.
You can send data trough the intent and then set this data to the textfield
In your sender Activity
Intent myIntent = new Intent(this, GenreClass.class);
myIntent.putExtra("genre","rock");
startActivity(myIntent);
In the receiver Activity
Intent myIntent = getIntent();
String genre = myIntent.getStringExtra("genre");
myTextView.setText(genre)

Android - Show set wallpaper button when image selected

i want to create wallpaper app.
i want user click image show whole image and visible set wallpaper button.
like this pictures
after licked like this
The problem is to show set wallpaper button when image clicked and show whole image.
Thank you!
to display all image display activity use recyclerview with GridLayoutManagerlike this
private GridLayoutManager lLayout;
lLayout = new GridLayoutManager(MainActivity.this, 2);
recyclerview.setLayoutManager(lLayout);
check this link for how to use recyclerview with GridLayoutManager
for display image create a new activity and pass the image when user select image from recyclerview to that activity and display
Ask me in case of any query

Change logo programmatically in Fragment

How to change the title bar inside a fragment? Somewhat I am not able to succeed.
setTitle("My new title");
getActionBar().setIcon(R.drawable.my_icon);
I think the problem is that you can't access the ActionBar APIs from the fragment. So, what you need is an access to the Parent Activity.
Try : getActivity().setTitle("My new title");

How to add item to top menu on android

I want to add a a menu item to the top (Where the class title is). I added the item to menu.xml and also for made an Intent to open a new class after clicking but it does not open my whole app anymore. And when I remove android:onClick:"history" it starts working again with out the menu function of course.
Have a look at the picture please: http://snag.gy/udxXc.jpg
That 'History' is my button that needs to open a new class. and this is my code:
xml:
<item
android:id="#+id/history"
android:showAsAction="always"
android:title="History"
android:onClick="history"/>
Java:
public void history(View view){
Intent historyIntent = new Intent(this, History.class);
startActivity(historyIntent);
}
Am i doing it correctly? or any better solution?
I want to add a a menu item to the top (Where the class title is)
That is called the action bar.
And when I remove android:onClick:"history" it starts working again with out the menu function of course.
I am not aware that android:onClick is valid for <item> elements.
Am i doing it correctly?
Not as far as I am aware.
or any better solution?
Override onOptionsItemSelected() and respond to the item click there.

Categories