사용자 프로필 페이지를 만들려고합니다.DB에서 URL 이미지를 ImageView에 표시하는 방법
저는 열심히했는데 json 개체를 검색하고 사용자 데이터를 SQL 데이터베이스에 저장하고 이러한 데이터 (문자열)를 이름과 이메일 같은 TextView에 표시합니다.
는 또한 동일한 데이터베이스에있는 사용자의 사진에 URL을 가지고 있지만 난 그냥 다른 텍스트 문자열과 같은 이미지 뷰에 URL 표시 ..
이누군가가 친절하게 어떻게 조정할하는 저를 보여줄 수를 검색 할 수 없습니다 그렇게하기위한 코드?
자바 초보자부터 생각해보십시오. 고맙습니다! ^^
public class DirectoryDetailMeActivity extends Activity {
String eid; //user ID
JSONParser jsonParser = new JSONParser();
private static final String url_veiw_directory = "http://www.myweb.com/android/include/directory_detail_me.php";
private static final String TAG_ID = "eid";
private static final String TAG_IMG = "photo";
private static final String TAG_NAME = "name";
private static final String TAG_EMAIL = "email";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.directory_detail_me);
new GetDirectoryDetails().execute();
}
class GetDirectoryDetails extends AsyncTask<String, String, String> {
protected String doInBackground(String... params) {
runOnUiThread(new Runnable() {
public void run() {
int success;
try {
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("id", eid));
JSONObject json = jsonParser.makeHttpRequest(url_veiw_directory, "GET", params);
Log.d("my profile", json.toString());
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
JSONArray directoryObj = json.getJSONArray(TAG_DIRECTORY);
JSONObject directory = directoryObj.getJSONObject(0);
// It works fine if I give the URL manually.
String imageURL = "";
ImageView imagePhoto = (ImageView) findViewById(R.id.photo);
ImageLoader imgLoader = new ImageLoader(getApplicationContext());
imgLoader.DisplayImage(imageURL, imagePhoto);
TextView txtName = (TextView) findViewById(R.id.name);
TextView txtEmail = (TextView) findViewById(R.id.email);
txtName.setText(directory.getString(TAG_NAME));
txtEmail.setText(directory.getString(TAG_EMAIL));
}else{
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
에 (TAG_IMG을)이 라인
을 변경? 문제인가, 아니면 imageLoader인가? 너 – Zoleas
? String imageURL = directory.getString (TAG_IMG); – user1781367
할 때 String imageURL = directory.getString (TAG_IMG); 문자열이 null입니까? 그렇다면 json 문자열을 로깅 할 수 있습니까? – Zoleas