本文整理汇总了Java中android.support.v7.widget.CardView.addView方法的典型用法代码示例。如果您正苦于以下问题:Java CardView.addView方法的具体用法?Java CardView.addView怎么用?Java CardView.addView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.CardView
的用法示例。
在下文中一共展示了CardView.addView方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SetNewContents
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void SetNewContents(int key) {
if (!Changes(key).equals("null")) {
CardView.LayoutParams param = new CardView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
CardView card = new CardView(this);
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("DARK_THEME_KEY", false))
card.setCardBackgroundColor(ContextCompat.getColor(this, R.color.DarkcolorPrimary));
card.setCardElevation(5);
card.setLayoutParams(param);
card.setPadding(ConvertTopx(15), ConvertTopx(15), ConvertTopx(15), ConvertTopx(15));
card.setUseCompatPadding(true);
TextView changes = new TextView(this);
changes.setGravity(Gravity.CENTER);
changes.setPadding(ConvertTopx(5), ConvertTopx(5), ConvertTopx(5), ConvertTopx(5));
changes.setText(Changes(key));
changes.setTypeface(Typeface.MONOSPACE);
if (firebaseRemoteConfig.getBoolean("mark_red") && key == 0)
changes.setTextColor(Color.RED);
card.addView(changes);
layout.addView(card);
}
bar.setVisibility(View.GONE);
}
示例2: init
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void init() {
LinearLayout frame = new LinearLayout(context);
CardView card = new CardView(context);
card.setUseCompatPadding(true);
card.setContentPadding(MainActivity.dp(8), MainActivity.dp(8), MainActivity.dp(8), MainActivity.dp(8));
card.setCardElevation(12.f);
card.addView(layout);
frame.addView(card);
this.setContentView(frame);
this.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
this.setFocusable(true);
this.setBackgroundDrawable(new BitmapDrawable());
this.setOutsideTouchable(true);
}
示例3: onCreateViewHolder
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int position) {
View view;
if (mItems.get(position).cacheable()) {
if (mViews.containsKey(mItems.get(position))) {
view = mViews.get(mItems.get(position));
} else {
mViews.put(mItems.get(position), view = LayoutInflater.from(parent.getContext())
.inflate(mItems.get(position).getLayoutRes(), parent, false));
}
} else {
view = LayoutInflater.from(parent.getContext())
.inflate(mItems.get(position).getLayoutRes(), parent, false);
}
ViewGroup viewGroup = (ViewGroup) view.getParent();
if (viewGroup != null) {
viewGroup.removeView(view);
}
if (mItems.get(position).cardCompatible()
&& Prefs.getBoolean("forcecards", false, view.getContext())) {
CardView cardView = new CardView(view.getContext());
cardView.setRadius(view.getResources().getDimension(R.dimen.cardview_radius));
cardView.setCardElevation(view.getResources().getDimension(R.dimen.cardview_elevation));
cardView.setUseCompatPadding(true);
cardView.setFocusable(false);
cardView.addView(view);
view = cardView;
}
if (position == 0) {
mFirstItem = view;
}
mItems.get(position).setOnViewChangeListener(mOnViewChangedListener);
mItems.get(position).onCreateHolder(parent, view);
return new RecyclerView.ViewHolder(view) {
};
}
示例4: initZoomRegionView
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
/**
* Init the ZoomRegionView for navigate into image when user zoom in
*/
private void initZoomRegionView() {
if (mZoomRegionView == null) {
Bitmap init = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
mContentBitmap = init.copy(Bitmap.Config.ARGB_8888, true);
init.recycle();
mContentCanvas = new Canvas(mContentBitmap);
FrameLayout.LayoutParams layoutParams = new LayoutParams(getWidth() / 4, getHeight() / 4,
Gravity.TOP | Gravity.END);
layoutParams.setMargins(12, 12, 12, 12);
mZoomRegionCardView = new CardView(getContext());
mZoomRegionCardView.setLayoutParams(layoutParams);
mZoomRegionCardView.setPreventCornerOverlap(true);
mZoomRegionCardView.setRadius(0f);
mZoomRegionCardView.setUseCompatPadding(true);
mZoomRegionCardView.setVisibility(View.INVISIBLE);
CardView.LayoutParams childLayoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
mZoomRegionView = new ZoomRegionView(getContext());
mZoomRegionView.setLayoutParams(childLayoutParams);
mZoomRegionView.setScaleType(ImageView.ScaleType.CENTER_CROP);
mZoomRegionView.setOnZoomRegionListener(new ZoomRegionView.OnZoomRegionListener() {
@Override
public void onZoomRegionMoved(Rect newRect) {
mFromZoomRegion = true;
mZoomCenterX = newRect.centerX() * 4;
mZoomCenterY = newRect.centerY() * 4;
invalidate();
}
});
mZoomRegionCardView.addView(mZoomRegionView);
addView(mZoomRegionCardView);
}
}
示例5: addView
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public void addView(View child) {
if (child instanceof NavigationView) {
super.addView(child);
} else {
CardView cardView = new CardView(getContext());
cardView.setRadius(0);
cardView.addView(child);
cardView.setCardElevation(0);
frameLayout.addView(cardView);
}
}
示例6: setAppointmentTexts
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void setAppointmentTexts()
{
//Set the dynamic layout with appointment texts
if(fireBaseMap!=null) {
for (String s : appointmentTexts) {
//Card view of the dynamic layout
CardView cardView = new CardView(Appoinments.this);
LinearLayout.LayoutParams lp = (new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
150));
lp.setMargins(18, 20, 18, 20);
cardView.setLayoutParams(lp);
cardView.setCardBackgroundColor(0xff63D5C3);
cardView.setPadding(30, 30, 30, 30);
//Text view of the dynamic layout
TextView textView = new TextView(Appoinments.this);
LinearLayout.LayoutParams layoutParams = (new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));
textView.setLayoutParams(layoutParams);
textView.setGravity(Gravity.CENTER);
textView.setText(s);
textView.setTextColor(0xff000000); // hex color 0xAARRGGBB
textView.setTextSize(16);
textView.setTypeface(Typeface.create("monospace", Typeface.NORMAL));
//Add the text view to card view
cardView.addView(textView);
//Add the card view to linear layout
verticalLayout.addView(cardView);
}
//Set the number of appointments to a text view
String numberOfAppointments = getString(R.string.appointment) + String.valueOf(listOfAppointments.size());
appointmentTextView.setText(numberOfAppointments);
}
}
示例7: onCreateView
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
int index = getArguments().getInt("INDEX");
View v = inflater.inflate(R.layout.view_matrix_frag, container, false);
CardView cardView = (CardView) v.findViewById(R.id.DynamicCardView);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4");
String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd");
cardView.setCardElevation(Integer.parseInt(string));
cardView.setCardBackgroundColor(Color.parseColor(string2));
CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
GridLayout gridLayout = new GridLayout(getContext());
gridLayout.setRowCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow());
gridLayout.setColumnCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol());
for (int i = 0; i < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(); i++) {
for (int j = 0; j < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(); j++) {
TextView textView = new TextView(getContext());
textView.setGravity(Gravity.CENTER);
textView.setText(SafeSubString(GetText(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetElementof(i, j)), getLength()));
textView.setWidth(CalculatedWidth(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol()));
textView.setTextSize(SizeReturner(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(), ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(),
PreferenceManager.getDefaultSharedPreferences(getContext()).
getBoolean("EXTRA_SMALL_FONT", false)));
textView.setHeight(CalculatedHeight(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow()));
GridLayout.Spec Row = GridLayout.spec(i, 1);
GridLayout.Spec Col = GridLayout.spec(j, 1);
GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
gridLayout.addView(textView, params);
}
}
gridLayout.setLayoutParams(params1);
cardView.addView(gridLayout);
// Inflate the layout for this fragment
return v;
}
示例8: onCreateView
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final int index = getArguments().getInt("INDEX");
View v = inflater.inflate(R.layout.view_matrix_frag, container, false);
CardView cardView = (CardView) v.findViewById(R.id.DynamicCardView);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4");
String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd");
cardView.setCardElevation(Integer.parseInt(string));
cardView.setCardBackgroundColor(Color.parseColor(string2));
CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
GridLayout gridLayout = new GridLayout(getContext());
gridLayout.setRowCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow());
gridLayout.setColumnCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol());
for (int i = 0; i < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(); i++) {
for (int j = 0; j < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(); j++) {
final TextView textView = new TextView(getContext());
textView.setGravity(Gravity.CENTER);
textView.setTag(i * 10 + j);
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
final ProgressDialog progressDialog = new ProgressDialog(getContext());
progressDialog.setIndeterminate(false);
progressDialog.setMessage(getString(R.string.Calculating));
progressDialog.setProgress(ProgressDialog.STYLE_SPINNER);
progressDialog.setTitle(getString(R.string.Calculating));
progressDialog.show();
Runnable runnable = new Runnable() {
@Override
public void run() {
float res = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetMinorDeterminant(((int) textView.getTag()) / 10, ((int) textView.getTag()) % 10);
Message message = new Message();
Bundle bundle = new Bundle();
bundle.putInt("REX", ((int) textView.getTag()) / 10);
bundle.putInt("REY", ((int) textView.getTag()) % 10);
bundle.putFloat("VALUE", res);
message.setData(bundle);
progressDialog.dismiss();
handler.sendMessage(message);
}
};
Thread thread = new Thread(runnable);
thread.start();
}
});
textView.setText(SafeSubString(GetText(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetElementof(i, j)), getLenght()));
textView.setWidth(CalculatedWidth(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol()));
textView.setTextSize(SizeReturner(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(), ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(),
PreferenceManager.getDefaultSharedPreferences(getContext()).
getBoolean("EXTRA_SMALL_FONT", false)));
textView.setHeight(CalculatedHeight(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow()));
GridLayout.Spec Row = GridLayout.spec(i, 1);
GridLayout.Spec Col = GridLayout.spec(j, 1);
GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
gridLayout.addView(textView, params);
}
}
gridLayout.setLayoutParams(params1);
cardView.addView(gridLayout);
// Inflate the layout for this fragment
return v;
}
示例9: onCreateView
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View V = inflater.inflate(R.layout.fragment_edit, container, false);
CardView cardView = (CardView) V.findViewById(R.id.EditMatrixCard);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4");
String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd");
cardView.setCardElevation(Integer.parseInt(string));
cardView.setCardBackgroundColor(Color.parseColor(string2));
CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
int index = getArguments().getInt("INDEX");
Matrix m = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index);
GridLayout gridLayout = new GridLayout(getContext());
gridLayout.setRowCount(m.GetRow());
gridLayout.setColumnCount(m.GetCol());
for (int i = 0; i < m.GetRow(); i++) {
for (int j = 0; j < m.GetCol(); j++) {
EditText editText = new EditText(getContext());
editText.setId(i * 10 + j);
editText.setGravity(Gravity.CENTER);
if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("DECIMAL_USE", true)) {
editText.setInputType(InputType.TYPE_CLASS_NUMBER
| InputType.TYPE_NUMBER_FLAG_SIGNED);
} else {
editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
| InputType.TYPE_NUMBER_FLAG_SIGNED);
}
editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(getLength())});
if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("SMART_FIT_KEY", false)) {
editText.setWidth(ConvertTopx(62));
editText.setTextSize(SizeReturner(3, 3, PreferenceManager.getDefaultSharedPreferences(getContext()).
getBoolean("EXTRA_SMALL_FONT", false)));
} else {
editText.setWidth(ConvertTopx(CalculatedWidth(m.GetCol())));
editText.setTextSize(SizeReturner(m.GetRow(), m.GetCol(),
PreferenceManager.getDefaultSharedPreferences(getContext()).
getBoolean("EXTRA_SMALL_FONT", false)));
}
editText.setText(SafeSubString(GetText(m.GetElementof(i, j)), getLength()));
editText.setSingleLine();
GridLayout.Spec Row = GridLayout.spec(i, 1);
GridLayout.Spec Col = GridLayout.spec(j, 1);
GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
gridLayout.addView(editText, params);
}
}
gridLayout.setLayoutParams(params1);
cardView.addView(gridLayout);
RootView = V;
return V;
}
示例10: setup
import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
protected void setup(final LRecyclerView lRecyclerView) {
this.lRecyclerView = lRecyclerView;
lRecyclerView.setPullRefreshEnabled(false);
// for out cardview
// MAdapter adapter = new MAdapter(genData("item", 20, MODE_APPEND)) {
//
//
// @Override
// protected View onCreateItemView(ViewGroup parent, int viewType) {
// CardView cardView = new CardView(parent.getContext());
//
// View view = super.onCreateItemView(parent, viewType);
// cardView.addView(view);
// return cardView;
// }
// };
//for in cardview
MAdapter adapter = new MAdapter(genData("item", 20, MODE_APPEND)) {
@Override
protected View onCreateDecorItemView(ViewGroup viewGroup, View originView, int viewType) {
View view = super.onCreateDecorItemView(viewGroup, originView, viewType);
CardView cardView = new CardView(viewGroup.getContext());
cardView.addView(view);
return cardView;
}
};
SwipeMenuAdapterHelper swipeMenuAdapterHelper = new SwipeMenuAdapterHelper();
swipeMenuAdapterHelper.setSwipeMenuCreator(swipeMenuCreator);
swipeMenuAdapterHelper.setSwipeMenuItemClickListener(menuItemClickListener);
adapter.setSwipeMenuAdapterHelper(swipeMenuAdapterHelper);
//new LRecyclerView.DividerItemDecoration(getDrawable(R.drawable.divider)));
lRecyclerView.setLayoutManager(new LinearLayoutManager(this));
lRecyclerView.setAdapter(adapter);
// lRecyclerView.setItemViewSwipeEnabled(false);
}