Java Code Examples for android.widget.ListView#setBackground()

The following examples show how to use android.widget.ListView#setBackground() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: Musicoco   File: DialogUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static void showDetailDialog(Activity activity, SongInfo info) {
    DialogProvider manager = new DialogProvider(activity);

    String[] infos = new String[7];
    infos[0] = "歌曲:" + info.getTitle();
    infos[1] = "歌手:" + info.getArtist();
    infos[2] = "专辑:" + info.getAlbum();
    infos[3] = "时长:" + StringUtils.getGenTimeMS((int) info.getDuration());
    infos[4] = "格式:" + info.getMime_type();
    infos[5] = "大小:" + String.valueOf(info.getSize() >> 10 >> 10) + " MB";
    infos[6] = "路径:" + info.getData();

    View view = activity.getLayoutInflater().inflate(R.layout.list_image, null);
    ListView listView = (ListView) view.findViewById(R.id.list_image_list);
    ImageView imageView = (ImageView) view.findViewById(R.id.list_image_image);
    listView.setAdapter(new ArrayAdapter<String>(
            activity,
            R.layout.text_view_start,
            infos
    ));

    Bitmap b = BitmapUtils.bitmapResizeFromFile(
            info.getAlbum_path(),
            imageView.getWidth(),
            imageView.getHeight());
    if (b == null) {
        b = BitmapUtils.getDefaultPictureForAlbum(activity, imageView.getWidth(), imageView.getHeight());
    }

    if (b != null) {
        imageView.setImageBitmap(b);
    }

    ColorDrawable drawable = new ColorDrawable(Color.WHITE);
    drawable.setAlpha(245);
    listView.setBackground(drawable);

    manager.createFullyCustomDialog(view, "歌曲信息").show();
}
 
Example 2
Source Project: talkback   File: ListMenuManager.java    License: Apache License 2.0 5 votes vote down vote up
private View prepareCustomView(CharSequence[] items, AdapterView.OnItemClickListener listener) {
  ListView view = new ListView(service);
  view.setBackground(null);
  view.setDivider(null);
  ArrayAdapter<CharSequence> adapter =
      new ArrayAdapter<>(service, android.R.layout.simple_list_item_1, android.R.id.text1, items);
  view.setAdapter(adapter);
  view.setOnItemClickListener(listener);
  return view;
}