當前位置: 首頁>>代碼示例>>Java>>正文


Java CardView.addView方法代碼示例

本文整理匯總了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);
}
 
開發者ID:coder3101,項目名稱:Matrix-Calculator-for-Android,代碼行數:24,代碼來源:ChangeLogActivity.java

示例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);
}
 
開發者ID:Su-Yong,項目名稱:KakaoBot,代碼行數:18,代碼來源:SettingPopup.java

示例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) {
    };
}
 
開發者ID:morogoku,項目名稱:MTweaks-KernelAdiutorMOD,代碼行數:37,代碼來源:RecyclerViewAdapter.java

示例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);
    }
}
 
開發者ID:rosenpin,項目名稱:QuickDrawEverywhere,代碼行數:42,代碼來源:DrawView.java

示例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);
    }
}
 
開發者ID:shiburagi,項目名稱:Drawer-Behavior,代碼行數:13,代碼來源:AdvanceDrawerLayout.java

示例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);
    }

}
 
開發者ID:Nihal369,項目名稱:Amaro,代碼行數:42,代碼來源:Appoinments.java

示例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;
}
 
開發者ID:coder3101,項目名稱:Matrix-Calculator-for-Android,代碼行數:45,代碼來源:ViewMatrixFragment.java

示例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;

}
 
開發者ID:coder3101,項目名稱:Matrix-Calculator-for-Android,代碼行數:74,代碼來源:MinorChooserFragment.java

示例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;
}
 
開發者ID:coder3101,項目名稱:Matrix-Calculator-for-Android,代碼行數:60,代碼來源:EditFragment.java

示例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);
    }
 
開發者ID:leobert-lan,項目名稱:UiLib,代碼行數:48,代碼來源:MenuInCardSample.java


注:本文中的android.support.v7.widget.CardView.addView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。