正如我在标题中所说
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:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
</RelativeLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.achkars.espaceado"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.achkars.espaceado.MainActivity"
android:label="@string/app_name"
android:theme="@style/Theme.FullScreen"
android:noHistory="true"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
MainActivity.java
package com.achkars.espaceado;
import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
public class MainActivity extends Activity {
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webview = new WebView(this);
setContentView(webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebChromeClient(new WebChromeClient());
// Simplest usage: note that an exception will NOT be thrown
// if there is an error loading this page (see below).
webview.loadUrl("file:///android_asset/index.html");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
和文件 News.php
<html>
<head>
<link rel="stylesheet" type="text/css" href="file:///android_asset/style.css" media="screen"/>
</head>
<body>
<img alt="full screen background image" src="file:///android_asset/back.jpg" id="full-screen-background-image" />
<center><img alt="up" src="file:///android_asset/top.png" id="up" /> </center>
<center><img alt="down" src="file:///android_asset/down.png" id="down"/></center>
<h2><center>
Les nouvelles (Blagues)
</center></h2>
<ul>
<a href="file:///android_asset/index.html"><li class="arrow">La page precedente</li></a>
</ul>
<ul>
<?php
$con = mysql_connect("The Domain","Username","Password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DB Name", $con);
$result = mysql_query("SELECT * FROM espace");
while($row = mysql_fetch_array($result))
{
echo "<a href=".$row['link'].">","<li class=".$row['arrow'].">";
echo $row['news'];
echo "</li></a>";
};
mysql_close($con);
?>
</ul>
</body>
</html>
在PC上它工作正常,但在电话上我得到:
"," ";echo $row['news'}; echo "
";}; mysql_close($con); ?>
它需要任何许可吗?
感谢您的任何帮助