2012-07-22 27 views
0

我已經看到在logcat的輸出,但我不能看到我的聯繫人列表中的模擬器如何顯示其保存在清單列表<>

import java.util.List; 
import android.app.Activity; 
import android.os.Bundle; 
import android.util.Log; 
import android.widget.ListView; 


public class dbb extends Activity { 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    DatabaseHandler db = new DatabaseHandler(this); //i have created this class 

    /** 
    * CRUD Operations 
    * */ 
    // Inserting Contacts 
    Log.d("Insert: ", "Inserting .."); 
    db.addContact(new contact("Ravi", "9100000000")); 
    db.addContact(new contact("Srinivas", "9199999999")); 
    db.addContact(new contact("Tommy", "9522222222")); 
    db.addContact(new contact("Karthik", "9533333333")); 

// Reading all contacts 
    Log.d("Reading: ", "Reading all contacts.."); 
    List<contact> contacts = db.getAllContacts(); 
    ListView lv = new ListView(this); 
    lv = (ListView)findViewById(R.id.list1);   

for (contact cn : contacts) { 
     String log = "Id: "+cn.getID()+" ,Name: " + cn.getName() + " ,Phone: " + cn.getPhoneNumber(); 
      // Writing Contacts to log 
    Log.d("Name: ", log); 
    } 

    } 
} 

*//Here what should i do to show List[contact] as my desired output? which is saved in the list array. 

在此先感謝。

回答

0

我希望這有助於。此鏈接的第8點閱讀點click here。 :)