0

我有以下代码:

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  mSelectedContact = (NameOfList)parent.getItemAtPosition(position);
  if(mSelectedContact != null){
    String dn = mSelectedContact.getDisplayName();

    // Talking about this line here:
    String num = (mSelectedContact.getPhoneNumbers().toString()); 

    Log.i(TAG, dn + num);
    setContentView(R.layout.main1);
    LinearLayout mainLayout = (LinearLayout)findViewById(R.id.main_layout_id);
    LinearLayout Details = (LinearLayout)getLayoutInflater().inflate(R.layout.layout_item, null);
    TextView DisplayName = (TextView)Details.findViewById(R.id.contactsListView);                                       
    DisplayName.setText((dn) + (num));

    mainLayout.addView(Details);
  }
}
};

我希望标记的行显示电话号码的值,但它显示光标位置,如:

John Doe[android@40598908, android@40598800]

我将如何获得数字的价值?

4

1 回答 1

0

也许你只需要写 String num = (mSelectedContact.getPhoneNumbers()); 没有 toString() ,因为在 Java 中 toString() 方法返回对象的字符串表示,如 android@40598908。

于 2012-08-02T16:20:57.407 回答