android.widget.ListView.setBackgroundColor()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(168)

本文整理了Java中android.widget.ListView.setBackgroundColor()方法的一些代码示例,展示了ListView.setBackgroundColor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ListView.setBackgroundColor()方法的具体详情如下:
包路径:android.widget.ListView
类名称:ListView
方法名:setBackgroundColor

ListView.setBackgroundColor介绍

暂无

代码示例

代码示例来源:origin: gzu-liyujiang/AndroidPicker

@Override
@NonNull
protected LinearLayout makeCenterView() {
  LinearLayout rootLayout = new LinearLayout(activity);
  rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
  rootLayout.setOrientation(LinearLayout.VERTICAL);
  rootLayout.setBackgroundColor(Color.WHITE);
  ListView listView = new ListView(activity);
  listView.setBackgroundColor(Color.WHITE);
  listView.setDivider(new ColorDrawable(0xFFDDDDDD));
  listView.setDividerHeight(1);
  listView.setCacheColorHint(Color.TRANSPARENT);
  listView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
  listView.setAdapter(adapter);
  listView.setOnItemClickListener(this);
  rootLayout.addView(listView);
  emptyView = new TextView(activity);
  LinearLayout.LayoutParams txtParams = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
  txtParams.gravity = Gravity.CENTER;
  emptyView.setLayoutParams(txtParams);
  emptyView.setGravity(Gravity.CENTER);
  emptyView.setVisibility(View.GONE);
  emptyView.setTextColor(Color.BLACK);
  rootLayout.addView(emptyView);
  return rootLayout;
}

代码示例来源:origin: H07000223/FlycoDialog_Master

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  mDisplayMetrics = getResources().getDisplayMetrics();
  ListView lv = new ListView(mContext);
  lv.setCacheColorHint(Color.TRANSPARENT);
  lv.setBackgroundColor(Color.WHITE);
  lv.setFadingEdgeLength(0);
  lv.setAdapter(new SimpleHomeAdapter());
  lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
      Intent intent = new Intent(mContext, mClazzs[position]);
      startActivity(intent);
    }
  });
  setContentView(lv);
}

代码示例来源:origin: H07000223/FlycoDialog_Master

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  mDisplayMetrics = getResources().getDisplayMetrics();
  ListView lv = new ListView(mContext);
  lv.setCacheColorHint(Color.TRANSPARENT);
  lv.setBackgroundColor(Color.WHITE);
  lv.setFadingEdgeLength(0);
  lv.setAdapter(new SimpleHomeAdapter());
  lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
      Intent intent = new Intent(mContext, mClazzs[position]);
      startActivity(intent);
    }
  });
  setContentView(lv);
}

代码示例来源:origin: Ramotion/expanding-collection-android

@Override
  public void instantiateCard(LayoutInflater inflaterService, ViewGroup head, final ListView list, ECCardData data) {
    // Data object for current card
    CardDataImpl cardData = (CardDataImpl) data;
    // Set adapter and items to current card content list
    final List<String> listItems = cardData.getListItems();
    final CardListItemAdapter listItemAdapter = new CardListItemAdapter(getApplicationContext(), listItems);
    list.setAdapter(listItemAdapter);
    // Also some visual tuning can be done here
    list.setBackgroundColor(Color.WHITE);
    // Here we can create elements for head view or inflate layout from xml using inflater service
    TextView cardTitle = new TextView(getApplicationContext());
    cardTitle.setText(cardData.getCardTitle());
    cardTitle.setTextSize(COMPLEX_UNIT_DIP, 20);
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    head.addView(cardTitle, layoutParams);
    // Card toggling by click on head element
    head.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(final View v) {
        ecPagerView.toggle();
      }
    });
  }
};

代码示例来源:origin: Ramotion/expanding-collection-android

list.setDividerHeight((int) pxFromDp(getApplicationContext(), 0.5f));
list.setSelector(R.color.transparent);
list.setBackgroundColor(Color.WHITE);
list.setCacheColorHint(Color.TRANSPARENT);

代码示例来源:origin: yyued/SVGAPlayer-Android

this.listView.setBackgroundColor(Color.WHITE);

代码示例来源:origin: multidots/android-app-common-tasks

final ListView pList = new ListView(ctx);
pList.setLayoutParams(new LinearLayout.LayoutParams(500, 500));
pList.setBackgroundColor(Color.WHITE);

代码示例来源:origin: multidots/android-app-common-tasks

final ListView pList = new ListView(ctx);
pList.setLayoutParams(new LinearLayout.LayoutParams(500, 500));
pList.setBackgroundColor(Color.WHITE);

代码示例来源:origin: bifan-wei/HwTxtReader

public void setBackGroundColor(int color){
  mRootView.setBackgroundColor(color);
}

代码示例来源:origin: stackoverflow.com

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);

  final ListView listView = (ListView) findViewById(R.id.listView);
  listView.setBackgroundColor(Color.GREEN);

  String[] values = new String[]{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

  final ArrayAdapter<String> adapter = new Adapter(this, android.R.layout.simple_list_item_1, values);
  listView.setAdapter(adapter);
}

代码示例来源:origin: stackoverflow.com

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
           Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootview = inflater.inflate(R.layout.fragment_one, container, false);

ListView listView = (ListView)   rootview.findViewById(R.id.mobile_list2);

listView.setBackgroundColor(Color.WHITE);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    switch (position)
    {
      case 0:
        Intent intent = new Intent(One.this,AndroidClass.class);
        startActivity(intent);
    }
  }
});

 return rootview;
}

代码示例来源:origin: stackoverflow.com

ListView listview=new ListView(this);
listview.setBackgroundColor(Color.WHITE);

代码示例来源:origin: stackoverflow.com

ListView listview=new ListView(this);
listview.setBackgroundColor(Color.WHITE);

代码示例来源:origin: quaap/LaunchTime

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  getWindow().setBackgroundDrawable(new ColorDrawable(Color.DKGRAY));
  getListView().setBackgroundColor(Color.DKGRAY);
  // Display the fragment as the main content.
  getFragmentManager().beginTransaction()
      .replace(android.R.id.content, new SettingsFragment())
      .commit();
}

代码示例来源:origin: quaap/LaunchTime

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  getWindow().setBackgroundDrawable(new ColorDrawable(Color.DKGRAY));
  getListView().setBackgroundColor(Color.DKGRAY);
  // Display the fragment as the main content.
  getFragmentManager().beginTransaction()
      .replace(android.R.id.content, new SettingsFragment())
      .commit();
}

代码示例来源:origin: first087/Android-License-Fragment

@Override
protected void onFirstTimeLaunched(ArrayList<License> licenses) {
  ArrayList<String> titleList = new ArrayList<>();
  ArrayList<String> licenseList = new ArrayList<>();
  for (License license : licenses) {
    titleList.add(license.getTitle());
    licenseList.add(license.getLicense());
  }
  listView.setBackgroundColor(customUI.getTitleBackgroundColor());
  listView.setAdapter(new ListViewAdapter(titleList, licenseList));
}

代码示例来源:origin: iKrelve/KuaiHu

public void updateTheme() {
    isLight = ((MainActivity) mActivity).isLight();
    ll_menu.setBackgroundColor(getResources().getColor(isLight ? R.color.light_menu_header : R.color.dark_menu_header));
    tv_login.setTextColor(getResources().getColor(isLight ? R.color.light_menu_header_tv : R.color.dark_menu_header_tv));
    tv_backup.setTextColor(getResources().getColor(isLight ? R.color.light_menu_header_tv : R.color.dark_menu_header_tv));
    tv_download.setTextColor(getResources().getColor(isLight ? R.color.light_menu_header_tv : R.color.dark_menu_header_tv));
    tv_main.setBackgroundColor(getResources().getColor(isLight ? R.color.light_menu_index_background : R.color.dark_menu_index_background));
    lv_item.setBackgroundColor(getResources().getColor(isLight ? R.color.light_menu_listview_background : R.color.dark_menu_listview_background));
    mAdapter.notifyDataSetChanged();
  }
}

代码示例来源:origin: first087/Android-License-Fragment

@Override
protected void onRestoreState(Bundle savedInstanceState) {
  ArrayList<String> titleList   = savedInstanceState.getStringArrayList("license_title");
  ArrayList<String> licenseList = savedInstanceState.getStringArrayList("license_text");
  listView.setBackgroundColor(customUI.getTitleBackgroundColor());
  listView.setAdapter(new ListViewAdapter(titleList, licenseList));
}

代码示例来源:origin: KishanV/Android-Music-Player

void setList(){
  ListView listview;
  listview = new ListView(getContext());
  listview.setBackgroundColor(btmBack.Color0);
  listview.setLayoutParams(new LayoutParams(Menu.width,Menu.height - Ui.cd.getHt(70+120)));
  listview.setY(Ui.cd.getHt(50));
  listview.setDivider(null);
  listview.setX(0);
  listview.setY(Ui.cd.getHt(70));
  listview.setAdapter(new playListsAdapter(Menu){
    @Override
    public void onSelect(String Id) {
      songsBtns.this.onSelect(Id);
    }
  });
  Menu.addView(listview);
  init((int) (Menu.height - Ui.cd.getHt(70+120) + listview.getY()));
}

代码示例来源:origin: KishanV/Android-Music-Player

void setList(){
  ListView listview;
  listview = new ListView(getContext());
  listview.setBackgroundColor(btmBack.Color0);
  listview.setLayoutParams(new LayoutParams(Menu.width,Menu.height - Ui.cd.getHt(70+120)));
  listview.setY(Ui.cd.getHt(50));
  listview.setDivider(null);
  listview.setX(0);
  listview.setY(Ui.cd.getHt(70));
  listview.setAdapter(new playListsAdapter(Menu){
    @Override
    public void onSelect(String Id) {
      libreryBtns.this.onSelect(Id);
    }
  });
  Menu.addView(listview);
  init((int) (Menu.height - Ui.cd.getHt(70+120) + listview.getY()));
}

相关文章

ListView类方法