当前位置: 首页>>代码示例>>Java>>正文


Java LinearLayout.findViewById方法代码示例

本文整理汇总了Java中android.widget.LinearLayout.findViewById方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayout.findViewById方法的具体用法?Java LinearLayout.findViewById怎么用?Java LinearLayout.findViewById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.LinearLayout的用法示例。


在下文中一共展示了LinearLayout.findViewById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAccessoryView

import android.widget.LinearLayout; //导入方法依赖的package包/类
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;
}
 
开发者ID:hh-in-zhuzhou,项目名称:ShangHanLun,代码行数:27,代码来源:ATableViewCellAccessoryView.java

示例2: getView

import android.widget.LinearLayout; //导入方法依赖的package包/类
@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;
}
 
开发者ID:n76,项目名称:Symphony,代码行数:20,代码来源:SongAdapter.java

示例3: UserTagView

import android.widget.LinearLayout; //导入方法依赖的package包/类
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);
      }
    });
  }
 
开发者ID:MUFCRyan,项目名称:BilibiliClient,代码行数:23,代码来源:UserTagView.java

示例4: addTimesToLayout

import android.widget.LinearLayout; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:gregoreesmaa,项目名称:minu-poska-android,代码行数:20,代码来源:TimeTableBaseActivity.java

示例5: getActionItem

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
    * 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;
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:29,代码来源:QuickAction.java

示例6: initView

import android.widget.LinearLayout; //导入方法依赖的package包/类
@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);
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:19,代码来源:SettingsActivity.java

示例7: setViewSingleLine

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * 自定义布局——单行滚动
 */
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);
    }
}
 
开发者ID:sun-sky,项目名称:Marquee,代码行数:30,代码来源:MainActivity.java

示例8: populateDevices

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 *
 */
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));
    }
}
 
开发者ID:MBach,项目名称:home-automation,代码行数:53,代码来源:StoryActivity.java

示例9: bindView

import android.widget.LinearLayout; //导入方法依赖的package包/类
@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));
}
 
开发者ID:Elbehiry,项目名称:Viajes,代码行数:11,代码来源:SearchSuggestionAdapter.java

示例10: initView

import android.widget.LinearLayout; //导入方法依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:XListViewFooter.java

示例11: setColorPreview

import android.widget.LinearLayout; //导入方法依赖的package包/类
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);
			}
		});
	}
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:35,代码来源:ColorPickerView.java

示例12: inflateToastLayout

import android.widget.LinearLayout; //导入方法依赖的package包/类
@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;
}
 
开发者ID:JarvanMo,项目名称:MarsBootProject,代码行数:35,代码来源:MToast.java

示例13: DialogBox

import android.widget.LinearLayout; //导入方法依赖的package包/类
@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);
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:14,代码来源:DialogBox.java

示例14: show

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * 显示对话框
 */
@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();

}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:42,代码来源:DialogBox.java

示例15: onCreateInputView

import android.widget.LinearLayout; //导入方法依赖的package包/类
@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;
}
 
开发者ID:ROKOLabs,项目名称:ROKOmoji.Emoji.Keyboard.App-Android,代码行数:28,代码来源:KeyboardService.java


注:本文中的android.widget.LinearLayout.findViewById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。