80,360
社区成员
发帖
与我相关
我的任务
分享
package com.example.call;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import android.app.ListActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.SimpleAdapter;
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Button bImageButton =(Button) findViewById(R.id.callphone);
SimpleAdapter adapter=new SimpleAdapter(this, getDate(), R.layout.activity_main,
new String[]{"name","number","img"},
new int[]{R.id.peoplename,R.id.peoplenumber,R.id.callphones});
setListAdapter(adapter);
bImageButton.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
// TODO 自动生成的方法存根
Intent intent=new Intent(Intent.ACTION_CALL, Uri.parse("tel://1502203"));
startActivity(intent);
}});
}
public List<Map<String, Object>> getDate(){
List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
Map<String, Object> map=new HashMap<String, Object>();
map.put("name","sue" );
map.put("number", "13012259133");
map.put("img", R.drawable.imgcall_phone);
list.add(map);
map=new HashMap<String, Object>();
map.put("name","alice" );
map.put("number", "15022037651");
map.put("img", R.drawable.imgcall_phone);
list.add(map);
return list;
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
tools:context="${packageName}.${activityClass}" >
<ImageButton
android:id="@+id/callphones"
android:layout_gravity="right"
android:layout_width="38dp"
android:layout_height="38dp"
android:src="@drawable/imgcall_phone"
android:background="#00000000"
android:layout_weight="1"
/>
<Button
android:id="@+id/callphone"
android:layout_gravity="right"
android:layout_width="38dp"
android:layout_height="38dp"
android:layout_weight="1"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="3" >
<TextView
android:id="@+id/peoplename"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#563624"
android:textSize="22sp"
/>
<TextView
android:id="@+id/peoplenumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#c7a252"
android:textSize="13sp"
/>
</LinearLayout>
</LinearLayout>