Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9156269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:44:11+00:00 2026-06-17T12:44:11+00:00

i have a problem with this overriding method on key press. the problem is

  • 0

i have a problem with this overriding method on key press. the problem is i got this error? i don’t know where I need to put this method in my activity.

This is my whole code:

public class UgWeb extends Activity {
    ListView list_ugweb;
    WebView web;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ugweb);
        list_ugweb = (ListView)findViewById(R.id.list_ugweb);
        @Override
        public boolean onKeyDown(int keyCode, KeyEvent event) 
        {
            if ((keyCode == KeyEvent.KEYCODE_BACK) && web.canGoBack())
            {
                web.goBack();
                return true;
            }
            return super.onKeyDown(keyCode, event);
        }

        String[] ugweb = new String[] {"Studentsite", "Staffsite", "BAAK", "Seminar", "Workshop", "Virtual Class", "iLab", "Gunadarma"};
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, ugweb)
                {
                    @Override
                    public View getView(int position, View convertView, ViewGroup parent)
                    {
                        View view = super.getView(position, convertView, parent);
                        TextView textview = (TextView)view.findViewById(android.R.id.text1);
                        textview.setTextColor(Color.WHITE);
                        return view;
                    }
                };
        list_ugweb.setAdapter(adapter);
        list_ugweb.setOnItemClickListener(new OnItemClickListener()
        {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int pos, long id)
            {
                String url;
                switch(pos)
                {
                    case 0 : url = "http://www.studentsite.gunadarma.ac.id"; 
                             webview(url);
                             break;
                    case 1 : url = "http://www.staffsite.gunadarma.ac.id";
                             webview(url);
                             break;
                    case 2 : url = "http://www.baak.gunadarma.ac.id";
                             webview(url);
                             break;
                    case 3 : url = "http://www.seminar.gunadarma.ac.id";
                             webview(url);
                             break;
                    case 4 : url = "http://www.lepkom.gunadarma.ac.id";
                             webview(url);
                             break;
                    case 5 : url = "http://www.v-class.gunadarma.ac.id";
                             webview(url);
                             break;
                    case 6 : url = "http://www.ilab.gunadarma.ac.id";
                             webview(url);
                             break;
                    case 7 : url = "http://www.gunadarma.ac.id";
                             webview(url);
                             break;
                    default : break;
                }
            }
        });
    }

    public void webview(String loadurl)
    {
        final String url = loadurl;
        setContentView(R.layout.webview);
        web = (WebView)findViewById(R.id.view);
        final Activity activity = UgWeb.this;
        final ProgressDialog progressdialog = new ProgressDialog(activity);
        progressdialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressdialog.setCancelable(true);
        web.getSettings().setBuiltInZoomControls(true);
        web.setWebChromeClient(new WebChromeClient()
        {
            public void onProgressChanged(WebView view, int progress)
            {
                progressdialog.show();
                progressdialog.setMessage("Please wait..");
                progressdialog.setProgress(0);
                activity.setProgress(progress * 1000);
                if(progress == 100 && progressdialog.isShowing())
                {
                    progressdialog.dismiss();
                }
            }
        });
        web.setWebViewClient(new WebViewClient());
        web.loadUrl(url);
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_ugsimpliy_beta, menu);
        return true;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:44:12+00:00Added an answer on June 17, 2026 at 12:44 pm

    Take this method after onCreate() :

    public class UgWeb extends Activity {
    
                @Override
                public void onCreate(Bundle savedInstanceState) {
                    .......
                }
    
                @Override
                public boolean onKeyDown(int keyCode, KeyEvent event) 
                {
                    if ((keyCode == KeyEvent.KEYCODE_BACK) && web.canGoBack())
                    {
                        web.goBack();
                        return true;
                    }
                    return super.onKeyDown(keyCode, event);
                }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with overriding the equals method in an Enum to make
I have a problem overriding the method where from...import statement is used. Some example
I have problem with this code: file = tempfile.TemporaryFile(mode='wrb') file.write(base64.b64decode(data)) file.flush() os.fsync(file) # file.seek(0)
I really have problem with this one. So I have a jar with a
Hi i have problem with this code, i found it on the internet and
i am a beginner and i have a problem : this code doesnt compile
I'm developing an Android application with a spinner. I have this problem: This is
I have this problem: I want to generate a new source code file from
I have this problem: $id is id for each user $img = 'http://www.somesite.com/pictures/'; $no_img
I have this problem since I'm beginning in OOP programming I want to close

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.