我在開發一個初學者,我知道這個問題可能聽起來很簡單,但讓我切入正題:這裏是我的類如何在打印功能中調用類?
public class MainActivity extends Activity {
private ListView lvPhone;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lvPhone = (ListView)findViewById(R.id.listPhone);
List<PhoneBook> listPhoneBook = new ArrayList<PhoneBook>();
listPhoneBook.add(new PhoneBook(
BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher),
"blah_blah", "384765345667", "[email protected]"));
listPhoneBook.add(new PhoneBook(
BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher),
"blah_blah", "34856834796", "[email protected]"));
listPhoneBook.add(new PhoneBook(
BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher),
"blah_name", "868734633", "[email protected]"));
PhoneBookAdapter adapter = new PhoneBookAdapter(this, listPhoneBook);
lvPhone.setAdapter(adapter);
}
}
,在這裏我想它被「附加」,所以然後當按鈕被點擊時,電話簿出現。
public void addListenerOnButton(){
imageButton = (ImageButton) findViewById(R.id.pb_button);
imageButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Toast.makeText(MyAndroidAppActivity.this,//phone_book goes here
"ImageButton is clicked!", Toast.LENGTH_SHORT).show();//no toaster instead
}
});
}
請問各位請幫忙嗎?這對我來說真的很有幫助。並請如果你回答,嘗試解釋爲你解釋爲「Java_moron」:)(儘可能通過請儘量通過)
[現在我嘗試了聊天室,沒有聲望點,所以沒有發生,我試圖谷歌儘可能找不到有用的東西;也許有答案,但我缺乏知識失敗了我。] 謝謝,
[編輯:或者,而不是使用電話簿類,我怎麼能從手機的本地聯繫人列表中調用聯繫人?任何事情都會有幫助。]
[啓動一個新的活動時間] [1] [1]:http://stackoverflow.com/questions/4227919/how-to-start-a-new-activity-from-anther -activity-in-android 這可能是你的意思。 – wufufufu 2013-03-24 21:47:12