This video will tell how to set menu items in android activity and how to perform action on that item.
We will learn about onCreateOptionsMenu() and onOptionsItemSelected() methods of menu.
Menus are like options given to the user.User can select any menu items form the menu.
Check out our website:
Follow Telusko on Twitter:
Follow on Facebook:
Telusko :
Navin Reddy :
Follow Navin Reddy on Instagram:
Subscribe to our other channel:
Navin Reddy :
Telusko Hindi :
Subscribe to the channel and learn Programming in easy way.
Java Tutorial for Beginners:
C Tutorial Playlist :
Android Tutorial for Beginners Playlist :
XML Tutorial :
Design Patterns in Java :
Socket Programming in Java :
Spring MVC Tutorial :
OpenShift Tutorial for Beginners :
Spring Framework with Maven :
Sql Tutorial for Beginners :
String Handling in Java :
Array in Java :
Java Servlet :
Exception Handling in Java :
Nguồn: https://valuedandloved.com
Xem thêm bài viết khác: https://valuedandloved.com/cong-nghe/
Xem thêm Bài Viết:
- Binary Option là gì? Giao dịch trên sàn Binary Option thực hiện như thế nào?
- Top CPU Tốt Nhất 2020 Cho Người Build PC
- Những lưu ý khi cài đặt và sử dụng phần mềm Microsoft Toolkit
- Hướng dẫn cách SEO Youtube lên Top 1 nhanh chóng
- Các khu vực này đều có tỷ lệ xét nghiệm dương tính trên 3% trong bảy ngày qua
getmenuinflater().inflate(r.menu.main_menu, menu) menu cannot be resolved in android studio
Please keep font size bigger.
Sir, please make a video on making a app browser please sir.
how do i do this with fragments ? stackoverflow answers did not help.. just cant get them to work
Sir is this also the another way to create menu?
plz make videos on network discovery and wifi p2p
Is this the only way to create a menu? I was looking for a more standard group of buttons to switch between activities.
package com.example.user.alertview;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;
public class Menu extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_menu);
}
@Override
public boolean onCreateOptionsMenu(android.view.Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.Settings:
Toast.makeText(this, "now you configure", Toast.LENGTH_SHORT).show();
return true;
case R.id.about:
Toast.makeText(this, "Dhwnia", Toast.LENGTH_SHORT).show();
return true;
case R.id.contact:
Toast.makeText(this, "Sah", Toast.LENGTH_SHORT).show();
return true;
}
}
}
I got error to get intent
Solution?
There are two buttons 1. Patient and 2. Doctor……. on clicking each of these popup menu appears….. then i added this onOptionsItemselected but it doesn't work at all…… nothing happens when i click the buttons under popup menu
here the java code…
public void onClickingPatient(View view){
PopupMenu popup = new PopupMenu(this,view);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.main_menu,popup.getMenu());
popup.show();
}
public void onClickingDoctor(View view){
PopupMenu popup = new PopupMenu(this,view);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.menu.doctor_menu,popup.getMenu());
popup.show();
}
@Override
public boolean onOptionsItemSelected(MenuItem item){
switch(item.getItemId()) {
case R.id.loginAsPatient:
View viewCurrent = LayoutInflater.from(MainActivity.this).inflate(R.layout.activity_login_details, null);
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage("Login Here");
builder.setView(viewCurrent);
break;
case R.id.loginAsDoctor:
break;
}
return false;
}
nice
i didnt have that menu folder
how to create that
Thumps Up (Y)