WEB开发网
开发学院手机开发Android 开发 Android获取Launcher 启动列表 阅读

Android获取Launcher 启动列表

 2010-06-22 19:18:00 来源:WEB开发网   
核心提示:tv.setPadding(10, 5, 0, 0);layout.addView(tv);return layout;}}public class LauncherAdapter extends BaseAdapter {Activity activity;public LauncherAdapter(Activit

tv.setPadding(10, 5, 0, 0);

layout.addView(tv);

return layout;

}

}

public class LauncherAdapter extends BaseAdapter {

Activity activity;

public LauncherAdapter(Activity a){

activity = a;

}

@Override

public int getCount() {

// TODO Auto-generated method stub

return lvalue.size();

}

@Override

public Object getItem(int arg0) {

// TODO Auto-generated method stub

return arg0;

}

@Override

public long getItemId(int position) {

// TODO Auto-generated method stub

return position;

}

@Override

public View getView(int position, View convertView, ViewGroup parent) {

// TODO Auto-generated method stub

return composeItem(position);

}

public View composeItem(int position){

LinearLayout layout = new LinearLayout(activity);

layout.setOrientation(LinearLayout.HORIZONTAL);

ImageView iv = new ImageView(activity);

iv.setImageDrawable(lvalue.get(position).icon);

layout.addView(iv);

TextView tv = new TextView(activity);

tv.setText(lvalue.get(position).name);

tv.setPadding(10, 5, 0, 0);

layout.addView(tv);

return layout;

}

}

4. 启动某个item 当单击时

Java代码

adapter = new LauncherAdapter(this);

lv.setAdapter(adapter);

lv.setOnItemClickListener(new OnItemClickListener(){

@Override

public void onItemClick(AdapterView arg0, View arg1, int arg2,

long arg3) {

// TODO Auto-generated method stub

Intent intent =new Intent(Intent.ACTION_VIEW);

intent.setComponent(lvalue.get(arg2).component);

上一页  1 2 3 4  下一页

Tags:Android 获取 Launcher

编辑录入:coldstar [复制链接] [打 印]
赞助商链接