本文整理匯總了Java中android.widget.ListView.setBackgroundColor方法的典型用法代碼示例。如果您正苦於以下問題:Java ListView.setBackgroundColor方法的具體用法?Java ListView.setBackgroundColor怎麽用?Java ListView.setBackgroundColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ListView
的用法示例。
在下文中一共展示了ListView.setBackgroundColor方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: makeCenterView
import android.widget.ListView; //導入方法依賴的package包/類
@Override
@NonNull
protected LinearLayout makeCenterView() {
LinearLayout rootLayout = new LinearLayout(activity);
rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
rootLayout.setBackgroundColor(Color.WHITE);
rootLayout.setOrientation(LinearLayout.VERTICAL);
ListView listView = new ListView(activity);
listView.setBackgroundColor(Color.WHITE);
listView.setDivider(new ColorDrawable(0xFFDDDDDD));
listView.setDividerHeight(1);
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
listView.setSelector(R.color.itemSelected);
listView.setCacheColorHint(Color.TRANSPARENT);
listView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
listView.setAdapter(adapter);
listView.setOnItemClickListener(this);
rootLayout.addView(listView);
return rootLayout;
}
示例2: setPopWindow
import android.widget.ListView; //導入方法依賴的package包/類
/**
* 獲取彈出視圖
*
* @return
*/
public void setPopWindow() {
ListView lv = new ListView(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(DensityUtil.dip2px(context, 150), ViewGroup.LayoutParams.WRAP_CONTENT);
lp.setMargins(15, 0, 15, 15);
lv.setLayoutParams(lp);
lv.setBackgroundColor(Color.WHITE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
lv.setElevation(15);
}
lv.setAdapter(new IconAdapter());
lv.setOnItemClickListener(this);
LinearLayout ll = new LinearLayout(context);
ll.setLayoutParams(new ViewGroup.LayoutParams(DensityUtil.dip2px(context, 200), ViewGroup.LayoutParams.WRAP_CONTENT));
ll.addView(lv);
pop = new PopupWindow(ll, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
pop.setTouchable(true);
pop.setOutsideTouchable(true);
//必須添加背景,否則點擊空白無法自動隱藏
pop.setBackgroundDrawable(new BitmapDrawable());
pop.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
if (changedListener != null) {
changedListener.onHide(FrmPopMenu.this);
}
}
});
}
示例3: onCreate
import android.widget.ListView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Make activity fullscreen
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
ActionBar supportActionBar = getSupportActionBar();
if (null != supportActionBar)
supportActionBar.hide();
setContentView(R.layout.ec_main_activity);
// Create adapter for pager
ECPagerViewAdapter adapter = new ECPagerViewAdapter(this, new ExampleDataset().getDataset()) {
@Override
public void instantiateCard(LayoutInflater inflaterService, ViewGroup head, ListView list, final ECCardData data) {
final CardData cardData = (CardData) data;
// Create adapter for list inside a card and set adapter to card content
CommentArrayAdapter commentArrayAdapter = new CommentArrayAdapter(getApplicationContext(), cardData.getListItems());
list.setAdapter(commentArrayAdapter);
list.setDivider(getResources().getDrawable(R.drawable.ec_list_divider));
list.setDividerHeight((int) pxFromDp(getApplicationContext(), 0.5f));
list.setSelector(R.color.ec_transparent);
list.setBackgroundColor(Color.WHITE);
list.setCacheColorHint(Color.TRANSPARENT);
// Add gradient to root header view
View gradient = new View(getApplicationContext());
gradient.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.MATCH_PARENT));
gradient.setBackgroundDrawable(getResources().getDrawable(R.drawable.ec_card_head_gradient));
head.addView(gradient);
// Inflate main header layout and attach it to header root view
inflaterService.inflate(R.layout.ec_simple_head, head);
// Set header data from data object
TextView title = (TextView) head.findViewById(R.id.ec_title);
title.setText(cardData.getHeadTitle());
ImageView avatar = (ImageView) head.findViewById(R.id.ec_avatar);
avatar.setImageResource(cardData.getPersonPictureResource());
TextView name = (TextView) head.findViewById(R.id.ec_name);
name.setText(cardData.getPersonName() + ":");
TextView message = (TextView) head.findViewById(R.id.ec_message);
message.setText(cardData.getPersonMessage());
TextView viewsCount = (TextView) head.findViewById(R.id.ec_social_views_count);
viewsCount.setText(" " + cardData.getPersonViewsCount());
TextView likesCount = (TextView) head.findViewById(R.id.ec_social_likes_count);
likesCount.setText(" " + cardData.getPersonLikesCount());
TextView commentsCount = (TextView) head.findViewById(R.id.ec_social_comments_count);
commentsCount.setText(" " + cardData.getPersonCommentsCount());
// Add onclick listener to card header for toggle card state
head.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
ecPagerView.toggle();
}
});
}
};
ecPagerView = (ECPagerView) findViewById(R.id.ec_pager_element);
ecPagerView.setPagerViewAdapter(adapter);
ecPagerView.setBackgroundSwitcherView((ECBackgroundSwitcherView) findViewById(R.id.ec_bg_switcher_element));
final ItemsCountView itemsCountView = (ItemsCountView) findViewById(R.id.ec_items_count_view);
ecPagerView.setOnCardSelectedListener(new ECPagerView.OnCardSelectedListener() {
@Override
public void cardSelected(int newPosition, int oldPosition, int totalElements) {
itemsCountView.update(newPosition, oldPosition, totalElements);
}
});
}
示例4: createView
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public View createView(final Context context) {
actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR);
actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR);
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("FontChange", R.string.FontChange));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
}
}
});
fragmentView = new FrameLayout(context);
fragmentView.setLayoutParams(new FrameLayout.LayoutParams(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
FrameLayout frameLayout = (FrameLayout) fragmentView;
listView = new ListView(context);
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
listView.setBackgroundColor(preferences.getInt("prefBGColor", 0xffffffff));
listView.setDivider(null);
listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false);
int def = preferences.getInt("themeColor", AndroidUtilities.defColor);
int hColor = preferences.getInt("prefHeaderColor", def);
AndroidUtilities.setListViewEdgeEffectColor(listView, /*AvatarDrawable.getProfileBackColorForId(5)*/ hColor);
frameLayout.addView(listView);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.gravity = Gravity.TOP;
listView.setLayoutParams(layoutParams);
initFonts(context);
return fragmentView;
}
示例5: createView
import android.widget.ListView; //導入方法依賴的package包/類
@Override
public View createView(final Context context) {
actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR);
actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR);
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("ThemeStore", R.string.ThemeStore));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
}
}
});
fragmentView = new FrameLayout(context);
fragmentView.setLayoutParams(new FrameLayout.LayoutParams(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
FrameLayout frameLayout = (FrameLayout) fragmentView;
listView = new ListView(context);
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
listView.setBackgroundColor(preferences.getInt("prefBGColor", 0xffffffff));
listView.setDivider(null);
listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false);
int def = preferences.getInt("themeColor", AndroidUtilities.defColor);
int hColor = preferences.getInt("prefHeaderColor", def);
AndroidUtilities.setListViewEdgeEffectColor(listView, /*AvatarDrawable.getProfileBackColorForId(5)*/ hColor);
frameLayout.addView(listView);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.gravity = Gravity.TOP;
listView.setLayoutParams(layoutParams);
progressDialog = new ProgressDialog(context);
progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setMessage(context.getString(R.string.Loading));
if (Cashing.themes.size() < 1) {
progressDialog.show();
new getThemes(context, constant.GET_THEMES).execute();
} else {
themes = Cashing.themes;
refreshDisplay(context);
}
return fragmentView;
}