2012-11-20 1 views
0

로그인 및 등록 기능을 갖춘 Android 애플리케이션을 개발하고있었습니다. 이 사이트의 튜토리얼과 예제에서 아주 좋은 시작을 얻었습니다 : http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/ 그러나 자습서에서는 데이터베이스에 데이터를 삽입하는 방법 (예 : 등록) 만 보여주고 새 페이지에 표시하는 방법은 보여주지 않았습니다. 이 튜토리얼에 기반한 이름 및 이메일과 같은 로그인 정보를 새로운 활동의 TextView 또는 Button 형식으로 표시하려고한다고 가정 해 보겠습니다. 데이터베이스에서 데이터를 가져 오려면 mainActivity 클래스에 어떤 코딩을 구현해야합니까? 다른 튜토리얼을 살펴 보았지만 메소드가 다르다. JSONParser 클래스와 Databasehandler 클래스를 함께 결합한 클래스도있다. 제가 이미 아주 오래 동안 노력 해왔음을 도와주세요, 정말 고마워요.새로운 활동 클래스 인 Android, PHP, SQL에 데이터베이스 정보 표시

다음은 XML과 액티비티 클래스에서 가져온 것입니다. 도와주세요.

XML 클래스

<!-- Display user info Label --> 
     <TextView 
      android:id="@+id/displayInfo" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="10dip" 
      android:textColor="#21dbd4" 
      android:textSize="20dip" /> 

활동 클래스

package com.example.trafficmaster; 

import org.json.JSONException; 
import org.json.JSONObject; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 
import android.widget.TextView; 

import com.example.trafficmaster.library.DatabaseHandler2; 
import com.example.trafficmaster.library.UserFunctions; 

public class HomeActivity extends Activity { 

    //JSON Response node names 
    private static String KEY_NAME = "name"; 
    private static String KEY_EMAIL = "email"; 


    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
      //Set View to home.xml 
      setContentView(R.layout.home); 


      TextView displayInfo = (TextView) findViewById(R.id.displayInfo); 

      //connect to database 
      UserFunctions userFunction = new UserFunctions(); 
     JSONObject json = ................... 
      displayInfo.setText(............); 

답변

관련 문제