Note that there are some explanatory texts on larger screens.

plurals
  1. POSave state of edittext
    primarykey
    data
    text
    <p>I am making a simple app. Here are the codes:</p> <p>Main xml:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" &gt; &lt;Button android:id="@+id/goButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:background="@drawable/layout1" android:text="@string/go" /&gt; &lt;EditText android:id="@+id/urlField" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_toLeftOf="@+id/goButton" android:background="@drawable/layout1" android:ems="10" android:inputType="textUri" android:hint="@string/enter_school_name"&gt; &lt;requestFocus /&gt; &lt;/EditText&gt; &lt;ProgressBar android:id="@+id/progressBar" style="?android:attr/progressBarStyleHorizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_below="@+id/urlField" /&gt; &lt;WebView android:id="@+id/webView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_below="@+id/progressBar" /&gt; </code></pre> <p></p> <p>Main Java:</p> <pre><code> package com.nextgenintl.plusportals; import android.annotation.SuppressLint; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; @SuppressLint("SetJavaScriptEnabled") public class MainActivity extends Activity { private WebView webView; private EditText urlEditText; private ProgressBar progress; @Override public void onBackPressed() { if (webView.copyBackForwardList().getCurrentIndex() &gt; 0) { webView.goBack(); } else { // Your exit alert code, or alternatively line below to finish super.onBackPressed(); // finishes activity } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); urlEditText = (EditText) findViewById(R.id.urlField); webView = (WebView) findViewById(R.id.webView); webView.setWebChromeClient(new MyWebViewClient()); progress = (ProgressBar) findViewById(R.id.progressBar); progress.setMax(100); Button openUrl = (Button) findViewById(R.id.goButton); openUrl.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { String url = urlEditText.getText().toString(); String urlSchool = "https://www.plusportals.com/"+url; urlSchool = urlSchool.replace(" ", ""); if (validateUrl(url)) { webView.getSettings().setJavaScriptEnabled(true); webView.loadUrl(urlSchool); MainActivity.this.progress.setProgress(0); } } private boolean validateUrl(String url) { return true; } }); } private class MyWebViewClient extends WebChromeClient { @Override public void onProgressChanged(WebView view, int newProgress) { MainActivity.this.setValue(newProgress); super.onProgressChanged(view, newProgress); } } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } public void setValue(int progress) { this.progress.setProgress(progress); } } </code></pre> <p>So, I want to save the user input - the school name, so you don't have to type it every single time. But I can't really figure it out - can you please help me??? Thanks if you post me the full java file.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload