android.view.LayoutInflater Java Examples

The following examples show how to use android.view.LayoutInflater. 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 check out the related API usage on the sidebar.
Example #1
Source File: ButtonCL_Fragment.java    From ui with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View myView = inflater.inflate(R.layout.constraintlayout_fragment, container, false);
    //set it up so all the button work in this fragment.
    (myView.findViewById(R.id.button01)).setOnClickListener(this);
    (myView.findViewById(R.id.button02)).setOnClickListener(this);
    (myView.findViewById(R.id.button03)).setOnClickListener(this);
    (myView.findViewById(R.id.button04)).setOnClickListener(this);
    (myView.findViewById(R.id.button05)).setOnClickListener(this);
    (myView.findViewById(R.id.button06)).setOnClickListener(this);
    (myView.findViewById(R.id.button07)).setOnClickListener(this);
    (myView.findViewById(R.id.button08)).setOnClickListener(this);
    (myView.findViewById(R.id.button09)).setOnClickListener(this);
    (myView.findViewById(R.id.button10)).setOnClickListener(this);
    (myView.findViewById(R.id.button11)).setOnClickListener(this);
    //output to the screen.
    output = myView.findViewById(R.id.output);
    return myView;
}
 
Example #2
Source File: TextRoundCornerProgressBar.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@SuppressLint("NewApi")
public TextRoundCornerProgressBar(Context context, AttributeSet attrs) {
	super(context, attrs);
	if (!isInEditMode()) {
		isProgressBarCreated = false;
		isProgressSetBeforeDraw = false;
		isMaxProgressSetBeforeDraw = false;
		isBackgroundColorSetBeforeDraw = false;
		isProgressColorSetBeforeDraw = false;
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		inflater.inflate(R.layout.round_corner_progress_bar_round_corner_with_text_layout, this);
		setup(context, attrs);
		isProgressBarCreated = true;
	} else {
		if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
			setBackground(new ColorDrawable(Color.parseColor("#CCCCCC")));
    	} else {
			setBackgroundColor(Color.parseColor("#CCCCCC"));
    	}
		setGravity(Gravity.CENTER);
           setPadding(0, (int)dp2px(5), 0, (int)dp2px(5));
		TextView tv = new TextView(context);
		tv.setText("TextRoundCornerProgressBar");
		addView(tv);
	}
}
 
Example #3
Source File: FolderDialog.java    From DroidPlay with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.folder_item, null);
    
    // service info
    File file = getItem(position);
    
    // name
    TextView name = (TextView) view.findViewById(R.id.name);
    if (file == null) {
    	name.setText("[ .. ]");
    } else {
    	name.setText(file.getName());
    }
    
    return (view);
}
 
Example #4
Source File: PluginSettingsDialog.java    From xposed-rimet with Apache License 2.0 6 votes vote down vote up
@Override
protected View createView(LayoutInflater layoutInflater, ViewGroup viewGroup) {

    // 不显示默认标题
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);

    mCommonFrameLayout = new CommonFrameLayout(getContext());
    mToolbar = mCommonFrameLayout.getTitleView();
    mMoreButton = mToolbar.addMoreImageButton();

    LinearLayout content = LayoutUtil.newCommonLayout(getContext());

    mListView = new ListView(getContext());
    mListView.setCacheColorHint(0x00000000);
    mListView.setDividerHeight(0);
    mListView.setLayoutParams(LayoutUtil.newMatchFrameLayoutParams());
    content.addView(mListView);

    mCommonFrameLayout.setContent(content);

    return mCommonFrameLayout;
}
 
Example #5
Source File: VMEditView.java    From VMLibrary with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化方法,获取属性等操作
 */
private void init(Context context, AttributeSet attrs) {
    LayoutInflater.from(context).inflate(R.layout.vm_widget_edit, this);
    mInputView = findViewById(R.id.vm_edit_input_view);
    mClearIcon = findViewById(R.id.vm_edit_clear_icon);
    mEyeIcon = findViewById(R.id.vm_edit_eye_icon);

    // 定义默认值
    mTextColor = VMColor.byRes(R.color.vm_black_87);
    mTextSize = (int) VMDimen.sp2px(14);
    mHint = "";
    mLimit = "";
    mMode = Mode.TEXT;
    mEnableClear = true;
    mEnableEye = false;
    mClearRes = R.drawable.vm_ic_close;
    mEyeRes = R.drawable.vm_ic_eye_off;

    // 获取控件的属性值
    handleAttrs(context, attrs);

    initEditView();
}
 
Example #6
Source File: MySimpleArrayAdapter.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	View rowView = null;
	LayoutInflater inflater = (LayoutInflater) context
			.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	rowView = inflater.inflate(R.layout.rowlayout, parent, false);
	TextView textView = (TextView) rowView.findViewById(R.id.label);
	ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
	textView.setText(values[position]);
	// Change the icon for Windows and iPhone
	String s = values[position];
	if (s.startsWith("iPhone")) {
		imageView.setImageResource(R.drawable.no);
	} else {
		imageView.setImageResource(R.drawable.ok);
	}

	return rowView;
}
 
Example #7
Source File: RecipientAlternatesAdapter.java    From ChipsLibrary with Apache License 2.0 6 votes vote down vote up
public RecipientAlternatesAdapter(final Context context,final Cursor c,final long currentId,final int queryMode,final OnCheckedItemChangedListener listener)
{
super(context,c,0);
mLayoutInflater=LayoutInflater.from(context);
mCurrentId=currentId;
mCheckedItemChangedListener=listener;
if(queryMode==QUERY_TYPE_EMAIL)
  mQuery=Queries.EMAIL;
else if(queryMode==QUERY_TYPE_PHONE)
  mQuery=Queries.PHONE;
else
  {
  mQuery=Queries.EMAIL;
  Log.e(TAG,"Unsupported query type: "+queryMode);
  }
}
 
Example #8
Source File: ExoPlayerWrapperView.java    From RedReader with GNU General Public License v3.0 6 votes vote down vote up
private static ImageButton createButton(
		@NonNull final Context context,
		@NonNull final ViewGroup root,
		@DrawableRes final int image,
		@NonNull final OnClickListener clickListener) {

	final ImageButton ib = (ImageButton)LayoutInflater.from(context).inflate(R.layout.flat_image_button, root, false);

	final int buttonPadding = General.dpToPixels(context, 14);
	ib.setPadding(buttonPadding, buttonPadding, buttonPadding, buttonPadding);

	ib.setImageResource(image);

	ib.setOnClickListener(clickListener);

	return ib;
}
 
Example #9
Source File: BookmarkAdapter.java    From zxingfragmentlib with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int index, View view, ViewGroup viewGroup) {
  View layout;
  if (view instanceof LinearLayout) {
    layout = view;
  } else {
    LayoutInflater factory = LayoutInflater.from(context);
    layout = factory.inflate(R.layout.bookmark_picker_list_item, viewGroup, false);
  }

  if (!cursor.isClosed()) {
    cursor.moveToPosition(index);
    CharSequence title = cursor.getString(BookmarkPickerActivity.TITLE_COLUMN);
    ((TextView) layout.findViewById(R.id.bookmark_title)).setText(title);
    CharSequence url = cursor.getString(BookmarkPickerActivity.URL_COLUMN);
    ((TextView) layout.findViewById(R.id.bookmark_url)).setText(url);
  } // Otherwise... just don't update as the object is shutting down
  return layout;
}
 
Example #10
Source File: DashBoard.java    From AnLinux-Adfree with Apache License 2.0 6 votes vote down vote up
public void notifyUserForNethunter(){
    final ViewGroup nullParent = null;
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(getActivity());
    LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
    View view = layoutInflater.inflate(R.layout.notify1, nullParent);
    TextView textView = view.findViewById(R.id.textView);

    alertDialog.setView(view);
    alertDialog.setCancelable(false);
    alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            SharedPreferences.Editor editor = sharedPreferences.edit();
            editor.putBoolean("IsNethunterNotified", true);
            editor.apply();
            isNethunterNotified = sharedPreferences.getBoolean("IsNethunterNotified", false);
            dialog.dismiss();
        }
    });
    alertDialog.show();
    textView.setText(R.string.nethunter_warning_content);
}
 
Example #11
Source File: SettingsAdapter.java    From prebid-mobile-android with Apache License 2.0 6 votes vote down vote up
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    switch (viewType) {
        case VIEW_TYPE_GENERAL_SETTINGS:
            return new GeneralSettingsViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.view_general_settings, parent, false));
        case VIEW_TYPE_AD_SERVER_SETTINGS:
            return new AdServerSettingsViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.view_ad_server_settings, parent, false));
        case VIEW_TYPE_PREBID_SERVER_SETTINGS:
            return new PrebidServerSettingsViewholder(LayoutInflater.from(parent.getContext()).inflate(R.layout.view_prebid_server_settings, parent, false));
        case VIEW_TYPE_SUBMIT:
            return new SubmitViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.view_submit, parent, false));
        default:
            return new DividerViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.view_divider, parent, false));
    }
}
 
Example #12
Source File: PlaceHolderHolder.java    From AndroidTreeView with Apache License 2.0 6 votes vote down vote up
@Override
public View createNodeView(TreeNode node, PlaceItem value) {
    final LayoutInflater inflater = LayoutInflater.from(context);
    final View view = inflater.inflate(R.layout.layout_place_node, null, false);


    TextView placeName = (TextView) view.findViewById(R.id.place_name);
    placeName.setText(value.name);

    Random r = new Random();
    boolean like = r.nextBoolean();

    PrintView likeView = (PrintView) view.findViewById(R.id.like);
    likeView.setIconText(context.getString(like ? R.string.ic_thumbs_up : R.string.ic_thumbs_down));
    return view;
}
 
Example #13
Source File: PlayDialog.java    From xposed-aweme with Apache License 2.0 6 votes vote down vote up
@Override
protected View createView(LayoutInflater layoutInflater, ViewGroup viewGroup) {

    // 不显示默认标题
    getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);

    mCommonFrameLayout = new CommonFrameLayout(getContext());
    mToolbar = mCommonFrameLayout.getTitleView();

    mAutoPlayType = ViewUtil.newSpinnerItemView(getContext(),
            "播放方式", "",
            PlayUtil.getPlayTypeName(Constant.PlayType.TDEFAULT),
            PlayUtil.getPlayTypeName(Constant.PlayType.TIMING));

    mAutoPlaySleepTime = new EditTextItemView(getContext());
    mAutoPlaySleepTime.setName("播放休眠时间");
    mAutoPlaySleepTime.setExtendHint("未设置");
    mAutoPlaySleepTime.setUnit("秒");
    mAutoPlaySleepTime.setInputType(com.sky.xposed.common.Constant.InputType.NUMBER_SIGNED);

    mCommonFrameLayout.addContent(mAutoPlayType);
    mCommonFrameLayout.addContent(mAutoPlaySleepTime);

    return mCommonFrameLayout;
}
 
Example #14
Source File: MobileCellsPreferenceAdapterX.java    From PhoneProfilesPlus with Apache License 2.0 5 votes vote down vote up
MobileCellsPreferenceAdapterX(Context context, MobileCellsPreferenceX preference)
{
    this.preference = preference;

    // Cache the LayoutInflate to avoid asking for a new one each time.
    inflater = LayoutInflater.from(context);
    this.context = context;
}
 
Example #15
Source File: PhotoEditor.java    From PhotoEditor with MIT License 5 votes vote down vote up
private PhotoEditor(Builder builder) {
    this.context = builder.context;
    this.parentView = builder.parentView;
    this.imageView = builder.imageView;
    this.deleteView = builder.deleteView;
    this.brushDrawingView = builder.brushDrawingView;
    this.isTextPinchZoomable = builder.isTextPinchZoomable;
    this.mDefaultTextTypeface = builder.textTypeface;
    this.mDefaultEmojiTypeface = builder.emojiTypeface;
    mLayoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    brushDrawingView.setBrushViewChangeListener(this);
    addedViews = new ArrayList<>();
    redoViews = new ArrayList<>();
}
 
Example #16
Source File: WeekCalendar.java    From WeekCalendar with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化View
 */
private void init(Context context, AttributeSet attrs) {
    this.context = context;
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.view_calender, this, true);
    mIvPrevious = (RelativeLayout) findViewById(R.id.iv_previous);
    preBtn = (ImageView) findViewById(R.id.pre_btn);
    nextBtn = (ImageView) findViewById(R.id.next_btn);
    mTvYearMouth = (TextView) findViewById(R.id.tv_year_mouth);
    month_layout = (RelativeLayout) findViewById(R.id.month_layout);
    mIvNext = (RelativeLayout) findViewById(R.id.iv_next);
    mRvDay = (ViewFlipper) findViewById(R.id.rv_day);
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.WeekCalendar);
    daysSelectedTextColor = typedArray.getColor(R.styleable
            .WeekCalendar_daysSelectedTextColor, Color.WHITE);
    todayTextColor = typedArray.getColor(R.styleable
            .WeekCalendar_todayTextColor, Color.GRAY);
    weekTextColor = typedArray.getColor(R.styleable
            .WeekCalendar_weekTextColor, Color.GRAY);
    weekBackgroundColor = typedArray.getColor(R.styleable
            .WeekCalendar_weekBackgroundColor, Color.WHITE);
    monthBackgroundColor = typedArray.getColor(R.styleable.WeekCalendar_monthBackgroundColor, Color.LTGRAY);
    monthTextColor = typedArray.getColor(R.styleable.WeekCalendar_monthTextColor, Color.WHITE);
    daysTextColor = typedArray.getColor(R.styleable.WeekCalendar_daysTextColor, Color.GRAY);
    nextArrowBg = typedArray.getDrawable(R.styleable.WeekCalendar_nextArrowBg);
    preArrowBg = typedArray.getDrawable(R.styleable.WeekCalendar_preArrowBg);
    daysSelectedBackground = typedArray.getDrawable(R.styleable.WeekCalendar_daysSelectedBackground);
    cornerMarkBg = typedArray.getDrawable(R.styleable.WeekCalendar_cornerMarkBg);
    hideTodayName = typedArray.getBoolean(R.styleable.WeekCalendar_hideTodayName, false);
    isCornerMark = typedArray.getBoolean(R.styleable.WeekCalendar_isCornerMark, false);
    daysTextSize = typedArray.getDimension(R.styleable.WeekCalendar_daysTextSize, 16f);
    weekTextSize = typedArray.getDimension(R.styleable.WeekCalendar_weekTextSize, 16f);
    isShowMonth = typedArray.getBoolean(R.styleable.WeekCalendar_isShowMonth, true);
    initDatas();
    initView();
    typedArray.recycle();
}
 
Example #17
Source File: OField.java    From hr with GNU Affero General Public License v3.0 5 votes vote down vote up
private void initLayout() {
    removeAllViews();
    if (useTemplate) {
        View layout = LayoutInflater.from(mContext).inflate(
                R.layout.base_control_template, this, false);

        if (withPadding) {
            int top_padding = layout.getPaddingTop();
            int right_padding = layout.getPaddingRight();
            int bottom_padding = layout.getPaddingBottom();
            int left_padding = layout.getPaddingLeft();
            if (!with_bottom_padding) {
                layout.setPadding(left_padding, top_padding, right_padding, 0);
            }
            if (!with_top_padding) {
                layout.setPadding(left_padding, 0, right_padding, bottom_padding);
            }
        } else {
            layout.setPadding(0, 0, 0, 0);
        }
        addView(layout);
        container = (ViewGroup) findViewById(R.id.control_container);
        img_icon = (ImageView) findViewById(android.R.id.icon);
        img_icon.setColorFilter(tint_color);
        setImageIcon();
    } else {
        container = this;
    }
}
 
Example #18
Source File: RegisterFragment.java    From FirebaseMessagingApp with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View fragmentView = inflater.inflate(R.layout.fragment_register, container, false);
    bindViews(fragmentView);
    return fragmentView;
}
 
Example #19
Source File: BaseFragment.java    From gank with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(getLayoutResId(), container, false);
    ButterKnife.bind(this, view);
    initPresenter();
    return view;
}
 
Example #20
Source File: DownloadAdapter.java    From Mysplash with GNU Lesser General Public License v3.0 5 votes vote down vote up
@NonNull
@Override
public DownloadHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    return new DownloadHolder(
            LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.item_download, parent, false)
    );
}
 
Example #21
Source File: MyCollectFragment.java    From KJFrameForAndroid with Apache License 2.0 5 votes vote down vote up
@Override
protected View inflaterView(LayoutInflater inflater, ViewGroup container,
                            Bundle bundle) {
    View root = View.inflate(outsideAty,
            R.layout.frag_pull_refresh_listview, null);
    return root;
}
 
Example #22
Source File: AddAddressAdapter.java    From Android with MIT License 5 votes vote down vote up
@Override
public AddAddressAdapter.AddressHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    context = parent.getContext();
    mContext = parent.getContext();
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_wallet_sele_address, parent, false);
    return new AddressHolder(view);
}
 
Example #23
Source File: CallsRecyclerViewAdapter.java    From BaldPhone with Apache License 2.0 5 votes vote down vote up
public CallsRecyclerViewAdapter(List<Call> callList, BaldActivity activity) {
    this.callList = callList;
    this.activity = activity;
    this.inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final TypedValue typedValue = new TypedValue();
    final Resources.Theme theme = activity.getTheme();
    theme.resolveAttribute(R.attr.bald_decoration_on_button, typedValue, true);
    textColorOnRegular = typedValue.data;
    theme.resolveAttribute(R.attr.bald_background, typedValue, true);
    this.letterContactBackground = new ColorDrawable(typedValue.data);
    this.randomColorMaker = new RandomColorMaker(typedValue.data);
    this.privateFace = activity.getDrawable(R.drawable.private_face_in_recent_calls);
    this.face = activity.getDrawable(R.drawable.face_in_recent_calls);
}
 
Example #24
Source File: BaseDialog.java    From Collection-Android with MIT License 5 votes vote down vote up
public void setContentView(int layoutRes){
	if(layoutRes!=0){
		this.mainView= LayoutInflater.from(context).inflate(layoutRes,null);
	}else{
		this.mainView=null;
	}

	create();
}
 
Example #25
Source File: CheckBoxRadioActivity.java    From Carbon with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActivityCheckboxRadioBinding binding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.activity_checkbox_radio, null, false);
    setContentView(binding.getRoot());

    initToolbar();

    binding.check.setOnClickListener(view -> binding.checkBox.setChecked(true));

    binding.uncheck.setOnClickListener(view -> binding.checkBox.setChecked(false));

    binding.checkBoxGroup.setOnCheckedChangeListener((buttonView, isChecked) -> {
        binding.checkBoxChild1.setChecked(isChecked);
        binding.checkBoxChild2.setChecked(isChecked);
    });

    CheckBox.OnCheckedChangeListener listener = (buttonView, isChecked) -> {
        if (binding.checkBoxChild1.isChecked() != binding.checkBoxChild2.isChecked()) {
            binding.checkBoxGroup.setChecked(CheckedState.INDETERMINATE);
        } else {
            binding.checkBoxGroup.setChecked(binding.checkBoxChild1.isChecked());
        }
    };
    binding.checkBoxChild1.setOnCheckedChangeListener(listener);
    binding.checkBoxChild2.setOnCheckedChangeListener(listener);
}
 
Example #26
Source File: SpinnerAdapter.java    From StreamHub-Android-SDK with MIT License 5 votes vote down vote up
@Override
public View getView(int position, View view, ViewGroup parent)
{
    if (view == null || !view.getTag().toString().equals("NON_DROPDOWN"))
    {
        LayoutInflater inflater = LayoutInflater.from(mContext);
        view = inflater.inflate(R.layout.custom_spinner_toolbar, parent, false);
        view.setTag("NON_DROPDOWN");
    }

    TextView textView = (TextView) view.findViewById(R.id.spinner_item_text);
    textView.setText(getTitle(position));
    return view;
}
 
Example #27
Source File: EditTransactionFragment.java    From budget-envelopes with GNU General Public License v3.0 5 votes vote down vote up
@Override public View onCreateInternalView(LayoutInflater inflater,
                                           ViewGroup cont, Bundle state) {
    View retVal = inflater.inflate(R.layout.spendfragment, cont, false);
    mAmount = (EditMoney) retVal.findViewById(R.id.amount);
    mAmount.setInputType(InputType.TYPE_CLASS_NUMBER|InputType.TYPE_NUMBER_FLAG_DECIMAL|InputType.TYPE_NUMBER_FLAG_SIGNED);
    mDescription = (EditText) retVal.findViewById(R.id.description);
    retVal.findViewById(R.id.delayed).setVisibility(View.GONE);
    retVal.findViewById(R.id.delay).setVisibility(View.GONE);
    retVal.findViewById(R.id.repeat).setVisibility(View.GONE);
    retVal.findViewById(R.id.frequency).setVisibility(View.GONE);
    return retVal;
}
 
Example #28
Source File: LinkDialog.java    From rcloneExplorer with MIT License 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        linkUrl = savedInstanceState.getString(SAVED_LINK_URL);
        isDarkTheme = savedInstanceState.getBoolean(SAVED_IS_DARK_THEME);
    }

    AlertDialog.Builder builder;
    if (isDarkTheme) {
        builder = new AlertDialog.Builder(context, R.style.DarkDialogTheme);
    } else {
        builder = new AlertDialog.Builder(context);
    }

    LayoutInflater inflater = ((FragmentActivity)context).getLayoutInflater();
    View view = inflater.inflate(R.layout.dialog_link, null);

    TextView textView = view.findViewById(R.id.text_view);
    textView.setText(linkUrl);
    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clipData = ClipData.newPlainText("Copied link", linkUrl);
            if (clipboardManager == null) {
                return;
            }
            clipboardManager.setPrimaryClip(clipData);
            Toasty.info(context, getString(R.string.link_copied_to_clipboard), Toast.LENGTH_SHORT, true).show();
        }
    });

    builder.setView(view)
            .setPositiveButton(R.string.ok, null);

    return builder.create();
}
 
Example #29
Source File: NewsFragmentCommon.java    From zhangshangwuda with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	// System.out.println("NewsFragmentCommon_onCreateView");
	LayoutInflater mInflater = MyApplication.getActivity()
			.getLayoutInflater();
	rootView = mInflater.inflate(R.layout.news_viewpager_listview, null);
	return rootView;
}
 
Example #30
Source File: WanAndroidBaseFragment.java    From WanAndroid with MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    if (rootView == null) {
        rootView = inflater.inflate(getLayoutId(), container, false);
    }
    ButterKnife.bind(this, rootView);
    return rootView;
}