Feb 23, 2022

Android Studio Back Button Implement In Android Studio

code box with copy button

HTML



        package in.app.androidpro.makemoneyonline;

        import androidx.appcompat.app.ActionBar;
        import androidx.appcompat.app.AppCompatActivity;
        
        
        import android.os.Bundle;
        import android.view.Menu;
        import android.view.MenuItem;
        import android.webkit.WebView;
        
        public class Card1 extends AppCompatActivity {
        
            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_card1);
        
        
                ActionBar actionBar = getSupportActionBar();
                if (actionBar != null) {
                    actionBar.setDisplayHomeAsUpEnabled(true);
                }
        
                    WebView webView;
                    webView = findViewById(R.id.webview);
                    webView.loadUrl("file:///android_asset/Start A YouTube Channel.html");
                }
        
            public boolean onOptionsItemSelected(MenuItem item){
                switch (item.getItemId()) {
                    case android.R.id.home:
                        finish();
                        return true;
                }
                return super.onOptionsItemSelected(item);
            }
        
            public boolean onCreateOptionsMenu(Menu menu) {
                return true;
        
            }
        }
        
        
    

Share:

0 Comments: