网站以安卓应用打开,但无法交互



所以我尝试使用android工作室将我正在处理的网站转换为Android应用程序

应用程序已成功构建,没有错误,单击时打开,但只是保持静态。我无法与之互动。 它只是停留在主页上,没有交互。 无法向上/向下/向左/向右滑动 布局不正确 无法单击搜索框 主站点确实适应不同的屏幕尺寸

你能帮我诊断一下吗?

activity_main.xml

<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"
tools:context=".MainActivity">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/webView" />
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>


</RelativeLayout>

主要活动.java

package tech.radhelper.radhelpertech;
import android.app.ListActivity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends ListActivity {
private WebView myWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myWebView = (WebView) findViewById(R.id.webView);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.loadUrl("https://radhelper.tech/");
myWebView.setWebViewClient(new WebViewClient());
}
@Override
public void onBackPressed() {
if(myWebView.canGoBack()) {
myWebView.goBack();
} else
super.onBackPressed();
}
}

AndroidManifest.xmml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="tech.radhelper.radhelpertech">
<uses-permission android:name="android.permission.INTERNET"></uses- 
permission>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

我通过将ListActivity更改为AppCompatActivity来使其工作

然后更改activity_main.xml

我使用的代码是:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context=".MainActivity">
<WebView
android:id="@+id/webView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></ListView>
</RelativeLayout>

我包装内容而不是填充/匹配父项。

感谢Abhinav Gupta的帮助。白干杯!

最新更新