我按照本教程进行操作,但遇到了一些问题(https://www.simplifiedcoding.net/android-recyclerview-and-cardview-tutorial/)。我有一个images
用列id
和命名的表images
。
这是我的 getData.php:
<?php
$sql = "SELECT * FROM images";
require_once('dbConnect.php');
$r = mysqli_query($con,$sql);
$result = array();
while($row = mysqli_fetch_array($r)){
array_push($result,array(
'name'=>$row['name'],
'url'=>$row['image']
));
}
echo json_encode(array('result'=>$result));
mysqli_close($con);
这是我的 config.java
package com.example.mdesigntemp;
import android.graphics.Bitmap;
public class ConfigChildItem {
public static String[] names;
public static String[] urls;
public static Bitmap[] bitmaps;
public static final String GET_URL = "http://www.kinandayu.com/image_content/getAllImage.php";
public static final String TAG_IMAGE_URL = "url";
public static final String TAG_IMAGE_NAME = "name";
public static final String TAG_JSON_ARRAY="result";
public ConfigChildItem(int i){
names = new String[i];
urls = new String[i];
bitmaps = new Bitmap[i];
}
}
logcat什么也没说,但是当我打开我的活动时我会强制停止,任何人都可以提供解决方案,提前感谢所有答案