Java Code Examples for android.widget.LinearLayout.findViewById()

The following are Jave code examples for showing how to use findViewById() of the android.widget.LinearLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ShangHanLun   File: ATableViewCellAccessoryView.java   View Source Code Vote up 7 votes
private static ImageView getAccessoryView(ATableViewCell cell, ATableViewCellAccessoryType accessoryType) {
    LinearLayout containerView = (LinearLayout) cell.findViewById(R.id.containerView);

    // check if accessoryView already exists for current cell before creating a new instance.
    ImageView accessoryView = (ImageView) containerView.findViewById(R.id.accessoryView);
    if (accessoryView == null) {
        Resources res = cell.getResources();

        // get marginRight for accessoryView, DisclosureButton has a different one.
        LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
        int marginRight = (int) res.getDimension(R.dimen.atv_cell_content_margin);
        if (accessoryType == ATableViewCellAccessoryType.DisclosureButton) {
            marginRight = (int) res.getDimension(R.dimen.atv_cell_disclosure_button_margin_right);
        }
        params.setMargins(0, 0, marginRight, 0);

        // setup.
        accessoryView = new ATableViewCellAccessoryView(cell.getContext());
        accessoryView.setId(R.id.accessoryView);
        accessoryView.setLayoutParams(params);

        containerView.addView(accessoryView);
    }

    return accessoryView;
}
 
Example 2
Project: Symphony   File: SongAdapter.java   View Source Code Vote up 6 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if( convertView == null ){
        //We must create a View:
        convertView = songInf.inflate(R.layout.song, parent, false);
    }        //map to song layout
    LinearLayout songLay = (LinearLayout) convertView;
    //get title and artist views
    TextView songView = (TextView) songLay.findViewById(R.id.song_title);
    TextView artistView = (TextView) songLay.findViewById(R.id.song_artist);
    //get song using position
    Song currSong = songs.get(position);
    //get title and artist strings
    songView.setText(currSong.getTitle());
    artistView.setText(currSong.getArtist());
    //set position as tag
    songLay.setTag(position);
    return songLay;
}
 
Example 3
Project: BilibiliClient   File: UserTagView.java   View Source Code Vote up 6 votes
public UserTagView(Context context, AttributeSet attrs, int defStyleAttr) {

    super(context, attrs, defStyleAttr);
    @SuppressLint("InflateParams")
    LinearLayout cardView = (LinearLayout) LayoutInflater.from(context)
        .inflate(R.layout.layout_user_tag_view, null);
    avatarView = (CircleImageView) cardView.findViewById(R.id.user_avatar);
    userNameText = (TextView) cardView.findViewById(R.id.user_name);

    ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
        getResources().getDimensionPixelSize(R.dimen.user_tag_view_height));
    this.addView(cardView, lp);

    cardView.setOnClickListener(view -> {

      if (mid != -1 && activity != null) {
        UserInfoDetailsActivity.launch(activity, name, mid, avatarUrl);
      } else if (onClickListener != null) {
        onClickListener.onClick(view);
      }
    });
  }
 
Example 4
Project: minu-poska-android   File: TimeTableBaseActivity.java   View Source Code Vote up 6 votes
protected void addTimesToLayout() {
    Log.i(TAG, "Adding period times to layout");
    List<LessonPeriod> periods = timetable.getAll(LessonPeriod.class);
    for (int i = 0; i < periods.size(); i++) {
        LessonPeriod lessonPeriod = periods.get(i);
        lessonNoMap.put(lessonPeriod.period, i);

        LinearLayout timeView = (LinearLayout) getLayoutInflater().inflate(R.layout.item_schedule_time, null);
        TextView scheduleNumberView = (TextView) timeView.findViewById(R.id.scheduleNumberView);
        TextView scheduleStartTimeView = (TextView) timeView.findViewById(R.id.scheduleStartTimeView);
        TextView scheduleEndTimeView = (TextView) timeView.findViewById(R.id.scheduleEndTimeView);

        scheduleNumberView.setText(Integer.toString(lessonPeriod.period));
        scheduleStartTimeView.setText(lessonPeriod.starttime);
        scheduleEndTimeView.setText(lessonPeriod.endtime);

        vTimes.addView(timeView);
    }
}
 
Example 5
Project: aos-MediaLib   File: QuickAction.java   View Source Code Vote up 6 votes
/**
    * Get action item {@link View}
    *
    * @param title action item title
    * @param icon {@link Drawable} action item icon
    * @param listener {@link View.OnClickListener} action item listener
    * @return action item {@link View}
    */
private View getActionItem(String title, Drawable icon, OnClickListener listener) {
    LinearLayout container	= (LinearLayout) inflater.inflate(R.layout.quick_action_item, null);

    ImageView img = (ImageView) container.findViewById(R.id.icon);
    TextView text = (TextView) container.findViewById(R.id.title);

    if (icon != null) {
        img.setImageDrawable(icon);
    }

    if (title != null) {
        text.setText(title);
    }

    if (listener != null) {
        container.setOnClickListener(listener);
    }

    return container;
}
 
Example 6
Project: TestChat   File: SettingsActivity.java   View Source Code Vote up 6 votes
@Override
public void initView() {
        headerLayout = (RelativeLayout) findViewById(R.id.rl_setting_header);
        account = (TextView) findViewById(R.id.tv_setting_account);
        nick = (TextView) findViewById(R.id.tv_tv_setting_nick);
        avatar = (RoundAngleImageView) findViewById(R.id.riv_setting_avatar);
        RelativeLayout notificationLayout = (RelativeLayout) findViewById(R.id.rl_setting_notification);
        ((TextView) notificationLayout.findViewById(R.id.tv_setting_item_title)).setText("通知提醒");
        notification = (SwitchCompat) findViewById(R.id.switch_setting_item_check);
        clear = (LinearLayout) findViewById(R.id.ll_setting_clear);
        ((TextView) clear.findViewById(R.id.tv_group_info_item_layout_title)).setText("清空所有的聊天记录");
        chatFlow = (TextView) clear.findViewById(R.id.tv_group_info_item_layout_value);
        logout = (Button) findViewById(R.id.btn_setting_logout);
        headerLayout.setOnClickListener(this);
        clear.setOnClickListener(this);
        logout.setOnClickListener(this);
        notification.setOnCheckedChangeListener(this);
}
 
Example 7
Project: Marquee   File: MainActivity.java   View Source Code Vote up 5 votes
/**
 * 自定义布局——单行滚动
 */
private void setViewSingleLine() {
    views2.clear();//记得加这句话,不然可能会产生重影现象
    for (int i = 0; i < data.size(); i++) {
        final int position = i;
        //设置滚动的单个布局
        LinearLayout moreView = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.item_view_single, null);
        //初始化布局的控件
        TextView tv1 = (TextView) moreView.findViewById(R.id.tv1);

        /**
         * 设置监听
         */
        moreView.findViewById(R.id.rl).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(getApplicationContext(), position + "你点击了" + data.get(position).toString(), Toast.LENGTH_SHORT).show();
            }
        });

        //进行对控件赋值
        tv1.setText(data.get(i).toString());

        //添加到循环滚动数组里面去
        views2.add(moreView);
    }
}
 
Example 8
Project: home-automation   File: StoryActivity.java   View Source Code Vote up 5 votes
/**
 *
 */
private void populateDevices() {
    final LinearLayout mainLinearLayout = findViewById(R.id.mainLinearLayout);
    final CardView addPictureCard = findViewById(R.id.addPictureCard);

    for (final DeviceDAO deviceDAO : story.getDevices()) {
        final View previousDeviceView = mainLinearLayout.findViewById(deviceDAO.getId());
        if (previousDeviceView != null) {
            mainLinearLayout.removeView(previousDeviceView);
        }
        final View deviceView = getLayoutInflater().inflate(R.layout.story_activity_card_device, mainLinearLayout, false);

        // Pass args to buttons in order to perfom some actions on the device
        Button deleteDevice = deviceView.findViewById(R.id.delete_device);
        deleteDevice.setTag(R.id.cardDevice, deviceDAO);

        Button configureDevice = deviceView.findViewById(R.id.configure_device);
        configureDevice.setTag(R.id.cardDevice, deviceDAO);

        deviceView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                showRemoveDeviceDialog(deviceDAO);
                return true;
            }
        });

        // Hide the text if the device has no NetBios name (should be improved by the way)
        TextView name = deviceView.findViewById(R.id.name);
        if (deviceDAO.getName() == null) {
            name.setVisibility(View.GONE);
        } else {
            name.setText(deviceDAO.getName());
        }

        TextView ip = deviceView.findViewById(R.id.ip);
        ip.setText(deviceDAO.getIP());
        TextView vendor = deviceView.findViewById(R.id.vendor);
        vendor.setText(deviceDAO.getVendor());

        // Show the lock icon if device is password protected
        if (deviceDAO.isProtected()) {
            ImageView lockIcon = deviceView.findViewById(R.id.lockIcon);
            lockIcon.setVisibility(View.VISIBLE);
        }

        deviceView.setId(deviceDAO.getId());
        mainLinearLayout.addView(deviceView, mainLinearLayout.indexOfChild(addPictureCard));
    }
}
 
Example 9
Project: Viajes   File: SearchSuggestionAdapter.java   View Source Code Vote up 5 votes
@Override
public void bindView(View view, Context context, Cursor cursor) {
    // reference
    LinearLayout root = (LinearLayout) view;
    TextView titleTextView = (TextView) root.findViewById(R.id.search_suggestion_item_title);

    // content
    final int index = cursor.getColumnIndex(SearchManager.SUGGEST_COLUMN_TEXT_1);
    titleTextView.setText(cursor.getString(index));
}
 
Example 10
Project: GitHub   File: XListViewFooter.java   View Source Code Vote up 5 votes
@SuppressLint("InflateParams")
private void initView(Context context) {
	mContext = context;
	LinearLayout moreView = (LinearLayout) LayoutInflater.from(mContext)
			.inflate(R.layout.xlistview_footer, null);
	addView(moreView);
	moreView.setLayoutParams(new LinearLayout.LayoutParams(
			android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT));

	mContentView = moreView.findViewById(R.id.xlistview_footer_content);
	mProgressBar = moreView.findViewById(R.id.xlistview_footer_progressbar);
	mHintView = (TextView) moreView
			.findViewById(R.id.xlistview_footer_hint_textview);
}
 
Example 11
Project: GitHub   File: XListViewFooter.java   View Source Code Vote up 5 votes
@SuppressLint("InflateParams")
private void initView(Context context) {
	mContext = context;
	LinearLayout moreView = (LinearLayout) LayoutInflater.from(mContext)
			.inflate(R.layout.xlistview_footer, null);
	addView(moreView);
	moreView.setLayoutParams(new LinearLayout.LayoutParams(
			android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT));

	mContentView = moreView.findViewById(R.id.xlistview_footer_content);
	mProgressBar = moreView.findViewById(R.id.xlistview_footer_progressbar);
	mHintView = (TextView) moreView
			.findViewById(R.id.xlistview_footer_hint_textview);
}
 
Example 12
Project: javaide   File: ColorPickerView.java   View Source Code Vote up 5 votes
public void setColorPreview(LinearLayout colorPreview, Integer selectedColor) {
	if (colorPreview == null)
		return;
	this.colorPreview = colorPreview;
	if (selectedColor == null)
		selectedColor = 0;
	int children = colorPreview.getChildCount();
	if (children == 0 || colorPreview.getVisibility() != View.VISIBLE)
		return;

	for (int i = 0; i < children; i++) {
		View childView = colorPreview.getChildAt(i);
		if (!(childView instanceof LinearLayout))
			continue;
		LinearLayout childLayout = (LinearLayout) childView;
		if (i == selectedColor) {
			childLayout.setBackgroundColor(Color.WHITE);
		}
		ImageView childImage = (ImageView) childLayout.findViewById(R.id.image_preview);
		childImage.setClickable(true);
		childImage.setTag(i);
		childImage.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				if (v == null)
					return;
				Object tag = v.getTag();
				if (tag == null || !(tag instanceof Integer))
					return;
				setSelectedColor((int) tag);
			}
		});
	}
}
 
Example 13
Project: MarsBootProject   File: MToast.java   View Source Code Vote up 5 votes
@SuppressLint("InflateParams")
private static View inflateToastLayout(CharSequence message, int type) {
    LinearLayout layout = new LinearLayout(appContext);
    LayoutInflater inflater = (LayoutInflater) appContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.custom_toast_container, null);
    layout.addView(view);

    LinearLayout customToastContainer = (LinearLayout) layout.findViewById(R.id.custom_toast_container);
    ImageView icon = (ImageView) layout.findViewById(R.id.icon);
    TextView text = (TextView) layout.findViewById(R.id.text);

    switch (type) {
        case TYPE_SUCCESS:
            icon.setImageDrawable(ContextCompat.getDrawable(appContext, R.drawable.ic_check_circle_white_24dp));
            customToastContainer.setBackground(ContextCompat.getDrawable(appContext, R.drawable.custom_toast_success_background));
            break;
        case TYPE_WARNING:
            icon.setImageDrawable(ContextCompat.getDrawable(appContext, R.drawable.ic_warning_white_24dp));
            customToastContainer.setBackground(ContextCompat.getDrawable(appContext, R.drawable.custom_toast_warn_background));
            break;
        case TYPE_ERROR:
            icon.setImageDrawable(ContextCompat.getDrawable(appContext, R.drawable.ic_error_white_24dp));
            customToastContainer.setBackground(ContextCompat.getDrawable(appContext, R.drawable.custom_toast_error_background));
            break;
        default:
            icon.setImageDrawable(ContextCompat.getDrawable(appContext, R.drawable.ic_info_white_24dp));
            customToastContainer.setBackground(ContextCompat.getDrawable(appContext, R.drawable.custom_toast_info_background));
            break;
    }

    text.setText(message);

    return layout;
}
 
Example 14
Project: yyox   File: DialogBox.java   View Source Code Vote up 5 votes
@SuppressLint("InflateParams")
public DialogBox(Context context) {

    this.context = context;
    mainView = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.kf5_dialog_layout, null);
    dialogTitle = (TextView) mainView.findViewById(R.id.kf5_dialogTitle);
    dialogText = (TextView) mainView.findViewById(R.id.kf5_dialogText);
    dialogText.setVisibility(View.GONE);
    dialogTitle.setVisibility(View.GONE);
    btnNames = new ArrayList<>();
    listeners = new onClickListener[2];
    dialog = new Dialog(context, R.style.kf5messagebox_style);
}
 
Example 15
Project: yyox   File: DialogBox.java   View Source Code Vote up 5 votes
/**
 * 显示对话框
 */
@SuppressLint("InflateParams")
public void show() {

    mainView.removeAllViews();
    if (!TextUtils.isEmpty(title)) {
        mainView.addView(dialogTitle);
        dialogTitle.setVisibility(View.VISIBLE);
        dialogTitle.setText(title);
    }
    if (!TextUtils.isEmpty(message)) {
        mainView.addView(dialogText);
        dialogText.setVisibility(View.VISIBLE);
        dialogText.setText(message);
    }
    if (listView != null) {
        mainView.addView(listView);
    }
    //只创建了一个按钮
    if (btnNames.size() == 1) {
        singleBtn = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.kf5_message_box_single_btn, null);
        TextView dialogBtn = (TextView) singleBtn.findViewById(R.id.kf5_dialogBtn);
        dialogBtn.setText(btnNames.get(0));
        dialogBtn.setOnClickListener(new ClickListener(0));
        mainView.addView(singleBtn);
    } else if (btnNames.size() == 2) {
        doubleBtn = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.kf5_message_box_double_btn, null);
        TextView leftBtn = (TextView) doubleBtn.findViewById(R.id.kf5_dialogLeftBtn);
        TextView rightBtn = (TextView) doubleBtn.findViewById(R.id.kf5_dialogRightBtn);
        leftBtn.setText(btnNames.get(0));
        leftBtn.setOnClickListener(new ClickListener(0));
        rightBtn.setText(btnNames.get(1));
        rightBtn.setOnClickListener(new ClickListener(1));
        mainView.addView(doubleBtn);
    }
    dialog.setContentView(mainView);
    dialog.show();

}
 
Example 16
Project: ROKOmoji.Emoji.Keyboard.App-Android   File: KeyboardService.java   View Source Code Vote up 5 votes
@Override
public View onCreateInputView() {
    mainBoard = (LinearLayout) getLayoutInflater().inflate(R.layout.main_board_layout, null);
    packNameLabel = (TextView) mainBoard.findViewById(R.id.packNameLabel);
    scrollView = (ScrollView) mainBoard.findViewById(R.id.gif_view);

    stickerView = (RecyclerView) getLayoutInflater().inflate(R.layout.recycler_view, null);
    stickerView.addItemDecoration(new MarginDecoration(this));
    stickerView.setHasFixedSize(true);
    stickerView.setLayoutManager(new GridLayoutManager(this, 6));

    scrollView.addView(stickerView);

    ImageView btShareLinkGP = (ImageView) mainBoard.findViewById(R.id.btShareLinkGP);
    btShareLinkGP.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            shareLinkToGP();
        }
    });

    // packs bar
    packView = (RecyclerView) mainBoard.findViewById(R.id.pack_recycler_view);

    showStickers();
    return mainBoard;
}
 
Example 17
Project: chromium-for-android-56-debug-video   File: ItemChooserDialog.java   View Source Code Vote up 4 votes
/**
 * Creates the ItemChooserPopup and displays it (and starts waiting for data).
 *
 * @param activity Activity which is used for launching a dialog.
 * @param callback The callback used to communicate back what was selected.
 * @param labels The labels to show in the dialog.
 */
public ItemChooserDialog(
        Activity activity, ItemSelectedCallback callback, ItemChooserLabels labels) {
    mActivity = activity;
    mItemSelectedCallback = callback;
    mLabels = labels;

    LinearLayout dialogContainer = (LinearLayout) LayoutInflater.from(mActivity).inflate(
            R.layout.item_chooser_dialog, null);

    mListView = (ListView) dialogContainer.findViewById(R.id.items);
    mProgressBar = (ProgressBar) dialogContainer.findViewById(R.id.progress);
    mStatus = (TextView) dialogContainer.findViewById(R.id.status);
    mTitle = (TextViewWithClickableSpans) dialogContainer.findViewById(
            R.id.dialog_title);
    mEmptyMessage =
            (TextViewWithClickableSpans) dialogContainer.findViewById(R.id.not_found_message);

    mTitle.setText(labels.title);
    mTitle.setMovementMethod(LinkMovementMethod.getInstance());

    mEmptyMessage.setMovementMethod(LinkMovementMethod.getInstance());
    mStatus.setMovementMethod(LinkMovementMethod.getInstance());

    mConfirmButton = (Button) dialogContainer.findViewById(R.id.positive);
    mConfirmButton.setText(labels.positiveButton);
    mConfirmButton.setEnabled(false);
    mConfirmButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mItemSelectedCallback.onItemSelected(mItemAdapter.getSelectedItemKey());
            mDialog.setOnDismissListener(null);
            mDialog.dismiss();
        }
    });

    mItemAdapter = new ItemAdapter(mActivity, R.layout.item_chooser_dialog_row);
    mItemAdapter.setNotifyOnChange(true);
    mListView.setAdapter(mItemAdapter);
    mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mListView.setEmptyView(mEmptyMessage);
    mListView.setOnItemClickListener(mItemAdapter);
    mListView.setDivider(null);
    setState(State.STARTING);

    // The list is the main element in the dialog and it should grow and
    // shrink according to the size of the screen available.
    View listViewContainer = dialogContainer.findViewById(R.id.container);
    listViewContainer.setLayoutParams(new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT,
            getListHeight(mActivity.getWindow().getDecorView().getHeight(),
                    mActivity.getResources().getDisplayMetrics().density)));

    showDialogForView(dialogContainer);
}
 
Example 18
Project: Nimbus   File: Util.java   View Source Code Vote up 4 votes
public static AlertDialog promptRollNo(final AppCompatActivity context){
    final SharedPref sharedPref=new SharedPref(context);
    AlertDialog.Builder alertDialogBuilder=new AlertDialog.Builder(context);
    LayoutInflater inflater=context.getLayoutInflater();
    LinearLayout l= (LinearLayout) inflater.inflate(R.layout.dialog_register_rollno,null);
    alertDialogBuilder.setView(l);
    final CheckBox checkBox= (CheckBox) l.findViewById(R.id.checkbox_register);
    final EditText rollNoEditText= (EditText) l.findViewById(R.id.rollno_register);
    final EditText phoneNoEditText= (EditText) l.findViewById(R.id.phone_register);
    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if(isChecked){
                rollNoEditText.setVisibility(View.VISIBLE);
                phoneNoEditText.setVisibility(View.VISIBLE);
            }
            else {
                rollNoEditText.setVisibility(View.GONE);
                phoneNoEditText.setVisibility(View.GONE);
            }
        }
    });

    alertDialogBuilder.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent i=new Intent(context, UploadService.class);
            i.putExtra(REGISTER_ROLL_NO,true);
            i.putExtra(ROLL_NO,rollNoEditText.getText().toString());
            if(checkBox.isChecked()){
                sharedPref.setNitianStatus(true);
                sharedPref.setUserRollno(rollNoEditText.getText().toString());
                context.startService(i);
            }
            else{
                sharedPref.setNitianStatus(false);
                sharedPref.setUserRollno("");
            }


        }
    });
     return alertDialogBuilder.create();
}
 
Example 19
Project: CustomizableCalendar   File: MonthGridView.java   View Source Code Vote up 4 votes
private void bindViews() {
    LinearLayout calendarLayout = (LinearLayout) LayoutInflater.from(getContext()).inflate(layoutResId, this);
    calendarGrid = (GridView) calendarLayout.findViewById(android.R.id.widget_frame);
}
 
Example 20
Project: yyox   File: FeedBackDetailsActivity.java   View Source Code Vote up 4 votes
private View inflateHeaderView() {
    mHeaderView = (LinearLayout) LayoutInflater.from(this).inflate(R.layout.kf5_rating_header, null);
    mHeaderView.setOnClickListener(this);
    mHeaderContent = (TextView) mHeaderView.findViewById(R.id.kf5_rating_status);
    return mHeaderView;
}