parent
3d01465ced
commit
a295b4c140
Binary file not shown.
@ -0,0 +1,32 @@
|
|||||||
|
package com.example.ceshi;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
public class WebViewActivity extends AppCompatActivity {
|
||||||
|
private WebView mWebView;
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_web_view);
|
||||||
|
mWebView = (WebView) findViewById(R.id.web_view);
|
||||||
|
Intent intent = getIntent();
|
||||||
|
String url = "http://www.baidu.com";//intent.getStringExtra("url");
|
||||||
|
mWebView.loadUrl(url);
|
||||||
|
mWebView.getSettings().setJavaScriptEnabled(true);
|
||||||
|
mWebView.setWebViewClient(new WebViewClient(){
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
if (mWebView != null && mWebView.canGoBack()){
|
||||||
|
mWebView.goBack();
|
||||||
|
}else {
|
||||||
|
super.onBackPressed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,33 @@
|
|||||||
package com.example.ceshi;
|
package com.example.ceshi;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
public class second extends AppCompatActivity {
|
public class second extends AppCompatActivity {
|
||||||
|
private EditText mEditUrl;
|
||||||
|
private Button mBtnOpen;
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.secondview);
|
setContentView(R.layout.secondview);
|
||||||
|
|
||||||
|
mEditUrl = (EditText) findViewById(R.id.edit_url);
|
||||||
|
mBtnOpen = (Button) findViewById(R.id.btn_open);
|
||||||
|
mBtnOpen.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Intent intent = new Intent(second.this, WebViewActivity.class);
|
||||||
|
String url = "http://www.baidu.com";//mEditUrl.getText().toString();
|
||||||
|
intent.putExtra("url", url);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<WebView
|
||||||
|
android:id="@+id/web_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -1,27 +1,46 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="match_parent"
|
tools:context=".first">
|
||||||
tools:context=".first">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/five"
|
android:id="@+id/five"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="水果百科"
|
android:layout_marginBottom="349dp"
|
||||||
android:textSize="25dp"
|
android:text="水果百科"
|
||||||
android:textColor="#663399"
|
android:textColor="#663399"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
android:textSize="25dp"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintHorizontal_bias="0.497"
|
||||||
app:layout_constraintTop_toTopOf="parent" app:layout_constraintHorizontal_bias="0.497"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintVertical_bias="0.499"/>
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
<SearchView
|
app:layout_constraintTop_toBottomOf="@+id/edit_url"
|
||||||
android:layout_width="407dp"
|
app:layout_constraintVertical_bias="0.499" />
|
||||||
android:layout_height="100dp"
|
|
||||||
android:background="@drawable/green" tools:layout_editor_absoluteY="1dp" tools:layout_editor_absoluteX="1dp"
|
<EditText
|
||||||
tools:ignore="MissingConstraints"/>
|
android:id="@+id/edit_url"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="200dp"
|
||||||
|
android:layout_marginBottom="59dp"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/btn_open"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_open"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="573dp"
|
||||||
|
android:text="Button"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/edit_url" />
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources></resources>
|
Loading…
Reference in new issue