杨珺博10.23 333

develop
45951712 3 years ago
parent a295b4c140
commit b2d354400a

@ -7,11 +7,11 @@
<deviceKey>
<Key>
<type value="VIRTUAL_DEVICE_PATH" />
<value value="C:\Users\ZHY\.android\avd\Nexus_5X_API_30.avd" />
<value value="C:\Users\86188\.android\avd\Pixel_3a_API_33_x86_64.avd" />
</Key>
</deviceKey>
</Target>
</targetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-10-17T15:04:41.653934700Z" />
<timeTargetWasSelectedWithDropDown value="2022-10-21T10:44:09.320658400Z" />
</component>
</project>

@ -4,16 +4,18 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="delegatedBuild" value="false" />
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$PROJECT_DIR$/../gradle-6.6.1" />
<option name="gradleJvm" value="11" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="delegatedBuild" value="false" />
</GradleProjectSettings>
</option>
</component>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android API 33, extension level 3 Platform" project-jdk-type="Android SDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

@ -12,7 +12,6 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
@ -40,6 +39,7 @@
<activity android:name=".four"/>
<activity android:name=".collection"/>
<activity android:name=".WebViewActivity"/>
<activity android:name=".get"/>
<provider
android:authorities="com.example.takephoto.fileprovider"
android:name="androidx.core.content.FileProvider"

@ -8,14 +8,14 @@ import android.webkit.WebViewClient;
import androidx.appcompat.app.AppCompatActivity;
public class WebViewActivity extends AppCompatActivity {
private WebView mWebView;
public 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");
String url = "https://baidu.com//";//intent.getStringExtra("url");
mWebView.loadUrl(url);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new WebViewClient(){

@ -1,5 +1,6 @@
package com.example.ceshi;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
@ -18,6 +19,7 @@ public class first extends AppCompatActivity {
// Button button2 = findViewById(R.id.button2);
Button button3 = findViewById(R.id.button3);
Button button4 = findViewById(R.id.button4);
Button button5 = findViewById(R.id.test);
//按钮进行监听
button.setOnClickListener(new View.OnClickListener() {
@Override
@ -59,5 +61,15 @@ public class first extends AppCompatActivity {
startActivity(intent);
}
});
button5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//监听按钮,如果点击,就跳转
Intent intent = new Intent();
//前一个MainActivity.this是目前页面后面一个是要跳转的下一个页面
intent.setClass(first.this, get.class);
startActivity(intent);
}
});
}
}

@ -0,0 +1,100 @@
package com.example.ceshi;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;d
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.TextView;
public class get extends Activity {
// textview
private TextView mTextView;
// handler线程
private Handler mHandler = new Handler() {
public void handleMessage(android.os.Message msg) {
mTextView.setText((String) msg.obj);
};
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.get);
// 绑定id
mTextView = (TextView) findViewById(R.id.a);
}
// 联网
private void getHttp() {
InputStream stream = null;
InputStreamReader re = null;
BufferedReader reader = null;
try {
// 找水源
URL url = new URL("http://www.taobao.com");
// 建立总闸
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
// 建立水道
stream = conn.getInputStream();
// 捕鱼
// 小渔网
re = new InputStreamReader(stream);
// 大渔网
reader = new BufferedReader(re);
// 捞鱼
// 大水桶
String len = "";
// 小水桶
String temp = "";
while ((temp = reader.readLine()) != null) {
len += temp;
}
// 更新UI
Message sg = new Message();
sg.obj = len;
mHandler.sendMessage(sg);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
// 晒网,关闭资源
try {
if (reader != null) {
reader.close();
}
if (re != null) {
re.close();
}
if (stream != null) {
stream.close();
}
} catch (Exception e2) {
}
}
}
// 按钮监听
public void aaa(View v) {
//新建一个线程
new Thread() {
public void run() {
getHttp();
};
}.start();
}
}

@ -1,9 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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">
<WebView
android:id="@+id/web_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent"
tools:layout_editor_absoluteX="61dp"
tools:layout_editor_absoluteY="86dp">
<Button
android:id="@+id/button8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="307dp"
android:layout_y="666dp"
android:background="@android:color/holo_orange_light"
android:text="收藏" />
</WebView>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -43,6 +43,14 @@
android:layout_height="wrap_content" android:id="@+id/button4" app:backgroundTint="#FFB13B"
android:layout_below="@+id/one"
android:layout_marginTop="240dp"/>
<Button
android:id="@+id/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button4"
android:layout_marginBottom="-180dp"
android:text="test1" />
</RelativeLayout>

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<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"
>
<Button
android:id="@+id/a12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="获取"
android:onClick="aaa"
/>
<ScrollView
android:layout_below="@id/a12"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="获取网址内容" />
</ScrollView>
</RelativeLayout>
Loading…
Cancel
Save