Browser
parent
3a5948e3c1
commit
985d5d856e
|
@ -7,6 +7,8 @@
|
|||
<uses-sdk
|
||||
android:minSdkVersion="15"
|
||||
android:targetSdkVersion="18" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
<uses-sdk
|
||||
android:minSdkVersion="15"
|
||||
android:targetSdkVersion="18" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
Binary file not shown.
Binary file not shown.
|
@ -24,7 +24,9 @@ public final class R {
|
|||
public static final int ic_launcher=0x7f020000;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int action_settings=0x7f080000;
|
||||
public static final int action_settings=0x7f080002;
|
||||
public static final int editText=0x7f080001;
|
||||
public static final int webView=0x7f080000;
|
||||
}
|
||||
public static final class layout {
|
||||
public static final int activity_main=0x7f030000;
|
||||
|
|
|
@ -1,16 +1,37 @@
|
|||
<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" >
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
<WebView
|
||||
android:id="@+id/webView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/hello_world" />
|
||||
android:layout_weight="0.63" >
|
||||
</WebView>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="bottom" >
|
||||
|
||||
</RelativeLayout>
|
||||
<EditText
|
||||
android:id="@+id/editText"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.61"
|
||||
android:ems="10"
|
||||
android:singleLine="true"
|
||||
android:inputType="textUri">
|
||||
|
||||
<requestFocus />
|
||||
</EditText>
|
||||
|
||||
<Button
|
||||
android:onClick="onGo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="DIE" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -2,22 +2,70 @@ package com.thunder.simtech;
|
|||
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.view.Menu;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.EditText;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
}
|
||||
// The onCreate method is called when the Activity is created. Code to instantiate the UI should be placed here.
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// This call tells the system to inflate the user interface defined in main.xml as the User Interface for this Activity.
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
// The WebView needs to use a modified WebViewClient that does not delegate the URL to the default browser.
|
||||
final WebView webView = (WebView) findViewById(R.id.webView);
|
||||
webView.setWebViewClient(new WebViewClient() {
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url){
|
||||
view.loadUrl(url);
|
||||
|
||||
// Gets the editText
|
||||
EditText editText = (EditText) findViewById(R.id.editText);
|
||||
// Updates the URL
|
||||
editText.setText(webView.getUrl());
|
||||
|
||||
// Hides the soft keyboard
|
||||
editText.clearFocus();
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
return true;
|
||||
}
|
||||
return false; // Tells the system not to continue propagating the event.
|
||||
}
|
||||
});
|
||||
|
||||
webView.loadUrl("http://beta.typega.me:4006/dl/");
|
||||
|
||||
// You can add other code here if you want.
|
||||
}
|
||||
|
||||
}
|
||||
// Tell the Button you create to call this method, by setting the android:onCreate attribute.
|
||||
public void onGo(View view){
|
||||
WebView webView = (WebView) findViewById(R.id.webView);
|
||||
EditText editText = (EditText) findViewById(R.id.editText);
|
||||
|
||||
if (editText.getText()==null)return;
|
||||
String url = editText.getText().toString();
|
||||
|
||||
// if (url.equals("man man")) {
|
||||
// Intent i = new Intent(this, AboutActivity.class);
|
||||
// startActivity(i);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (!url.contains("http://"))url = "http://"+url;
|
||||
webView.loadUrl(url);
|
||||
Log.i("AndroidDemo", "Visiting: "+url);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue