Android нинг яратилиши тарихи
Download 57.67 Kb.
|
1-bilet
Menyu yaratishIlovalardagi menyular android.view.Menu klassi bilan ifodalanadi va har bir faoliyat ushbu turdagi ob'ekt bilan bog'lanadi. android.view.Menu obyekti o'zgaruvchan sonli elementlarni o'z ichiga olishi mumkin, ular o'z navbatida pastki elementlarni saqlashi mumkin.
package com.example.menuapp; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle;
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main_menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); TextView headerView = findViewById(R.id.selectedMenuItem); switch(id){ case R.id.action_settings : headerView.setText("Настройки"); return true; case R.id.open_settings: headerView.setText("Открыть"); return true; case R.id.save_settings: headerView.setText("Сохранить"); return true; } //headerView.setText(item.getTitle()); return super.onOptionsItemSelected(item); } } Download 57.67 Kb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling