本文整理汇总了Java中android.view.ViewGroup类的典型用法代码示例。如果您正苦于以下问题:Java ViewGroup类的具体用法?Java ViewGroup怎么用?Java ViewGroup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ViewGroup类属于android.view包,在下文中一共展示了ViewGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showChapter
import android.view.ViewGroup; //导入依赖的package包/类
public void showChapter() {
// TODO init draw tab
ViewGroup drawerTabs = (ViewGroup) findViewById(R.id.drawer_tab);
drawerTabs.getChildAt(0).setSelected(true);
Book book = readingFragment.getBook();
BookView bookView = readingFragment.getBookView();
List<List<Content>> chapters = book.getChapters();
List<CharSequence> chapterStr = new ArrayList<>();
for (List<Content> contents : chapters) {
Content firstContent = contents.get(0);
int pageNumber = bookView.getPageNumberFor(firstContent);
chapterStr.add(firstContent.getText() + " --- " + pageNumber);
}
mDrawerList.setAdapter(new ArrayAdapter<>(this,
R.layout.drawer_list_item, chapterStr));
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
mDrawerLayout.openDrawer(GravityCompat.START, true);
}
示例2: findView
import android.view.ViewGroup; //导入依赖的package包/类
/**
* Finds a view that is tagged with {@param nativeId} as its nativeID prop
* under the {@param root} view hierarchy. Returns the view if found, null otherwise.
* @param root root of the view hierarchy from which to find the view
*/
public static @Nullable View findView(View root, String nativeId) {
String tag = getNativeId(root);
if (tag != null && tag.equals(nativeId)) {
return root;
}
if (root instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) root;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View view = findView(viewGroup.getChildAt(i), nativeId);
if (view != null) {
return view;
}
}
}
return null;
}
示例3: getView
import android.view.ViewGroup; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if(convertView == null){
LayoutInflater inflater = getActivity().getLayoutInflater();
convertView = inflater.inflate(R.layout.item_city, null);
holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.text);
holder.root = convertView.findViewById(R.id.root);
convertView.setTag(holder);
}else{
holder = (ViewHolder) convertView.getTag();
}
County county = getItem(position);
holder.text.setText(county.getAreaName());
if(county.getAreaId().equals(currentCounty.getAreaId())){
holder.root.setBackgroundResource(R.color.commonF1B73F);
holder.text.setTextColor(getResources().getColor(R.color.white));
}else{
holder.root.setBackgroundResource(R.drawable.city_item_select);
holder.text.setTextColor(getResources().getColor(R.color.commonTextColor));
}
return convertView;
}
示例4: onCreateView
import android.view.ViewGroup; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_discover, container, false);
unbinder = ButterKnife.bind(this, v);
mType = DiscoverResultFragment.TYPE_MOVIES;
mGenresList = new HashSet<>();
mGenresValuesList = new HashSet<>();
checkedGenres = new boolean[] {
false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
};
ratingSeekBar.setOnSeekBarChangeListener(this);
final List<String> sort = Arrays.asList(getResources().getStringArray(R.array.sort));
ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), R.layout.spinner_item, sort);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sortSpinner.setAdapter(adapter);
sortSpinner.setOnItemSelectedListener(this);
return v;
}
示例5: getChildView
import android.view.ViewGroup; //导入依赖的package包/类
/**
* Instantiate a child view containing the user you following's habit and their individual completion status
* @param groupPosition
* @param childPosition
* @param isExpanded
* @param convertView
* @param parent
* @return
*/
@Override
public View getChildView(int groupPosition, int childPosition, boolean isExpanded, View convertView, ViewGroup parent) {
Habit habit = (Habit) getChild(groupPosition, childPosition);
if(convertView == null) {
convertView = mInflater.inflate(R.layout.item_following_habit, parent, false);
}
TextView titleView = (TextView) convertView.findViewById(R.id.following_habit_title);
titleView.setText(habit.getTitle());
ImageView indicatorView = (ImageView) convertView.findViewById(R.id.following_habit_indicator);
if (habit.getStatus() != null) {
indicatorView.setColorFilter(habit.getStatus().getColor());
}
return convertView;
}
示例6: onCreateDialogView
import android.view.ViewGroup; //导入依赖的package包/类
@NonNull
@Override
protected DialogView onCreateDialogView(@NonNull LayoutInflater inflater,
@NonNull ViewGroup container) {
return new DialogViewBuilder()
.title("I'm TITLE")
.message("I'm MESSAGE")
.stackButtons(true)
.positiveButton("Push an OpaqueController", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
getRouter().pushController(
RouterTransaction.with(new OpaqueController(getUseAttacher()))
.pushChangeHandler(getChangeHandler(OpaqueController.getRemoveFromViewOnPush()))
.popChangeHandler(getChangeHandler(OpaqueController.getRemoveFromViewOnPush()))
);
}
}).build(inflater, container);
}
示例7: onCreateView
import android.view.ViewGroup; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.assistant_account_creation_email_activation, container, false);
accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc()
, LinphonePreferences.instance().getXmlrpcUrl());
accountCreator.setDomain(getResources().getString(R.string.default_domain));
accountCreator.setListener(this);
username = getArguments().getString("Username");
password = getArguments().getString("Password");
accountCreator.setUsername(username);
accountCreator.setPassword(password);
email = (TextView) view.findViewById(R.id.send_email);
email.setText(getArguments().getString("Email"));
checkAccount = (Button) view.findViewById(R.id.assistant_check);
checkAccount.setOnClickListener(this);
return view;
}
示例8: instantiateItem
import android.view.ViewGroup; //导入依赖的package包/类
@Override public Object instantiateItem(ViewGroup container, int position) {
if (position == getCount() - 1) {
View inflate = View.inflate(context, R.layout.add_more_view, null);
container.addView(inflate);
if (onClickListener != null) {
inflate.findViewById(R.id.btn_add).setOnClickListener(onClickListener);
}
return inflate;
} else {
PhotoView photoView = new PhotoView(context);
//ViewGroup.LayoutParams layoutParams = photoView.getLayoutParams();
container.addView(photoView);
Glide.with(context).load(gankioDatas.get(position).getUrl()).into(photoView);
return photoView;
}
}
示例9: getView
import android.view.ViewGroup; //导入依赖的package包/类
@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
MyViewHolder holder = null;
if (row == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(R.layout.gv_geo_grid_view,null, true);
holder = new MyViewHolder(row);
row.setTag(holder);
} else {
holder = (MyViewHolder) row.getTag();
}
Typeface typeface = Typeface.createFromAsset(context.getAssets(), "fonts/grobold.ttf");
holder.mQueNo.setTypeface(typeface);
//holder.mtext.setTypeface(typeface);
holder.imageView.setImageResource(img[position]);
holder.mQueNo.setText(s[position]);
//holder.mtext.setText(strings[position]);
return row;
}
示例10: onCreateViewHolder
import android.view.ViewGroup; //导入依赖的package包/类
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//根据item类别加载不同ViewHolder
if(viewType==0){
View view = LayoutInflater.from(mContext).inflate(R.layout.recycler_item_small, parent, false);
//这个布局就是一个imageview用来显示图片
MyViewHolder holder = new MyViewHolder(view);
//给布局设置点击和长点击监听
view.setOnClickListener(this);
return holder;
}else{
MyViewHolder2 holder2=new MyViewHolder2(LayoutInflater.from(mContext).inflate(R.layout.recycler_test, parent,
false));
//这个布局就是一个textview用来显示页数
return holder2;
}
}
示例11: inflateView
import android.view.ViewGroup; //导入依赖的package包/类
@Override
protected View inflateView(ViewGroup parentView) {
if (context == null)
return null;
getValidationEngine().addEmailValidation(new RegexValidation(
Patterns.EMAIL_ADDRESS.pattern(), context.getString(R.string.invalid_email)));
if (context != null) {
View forgotPasswordView = LayoutInflater.from(context)
.inflate(R.layout.forgot_password, parentView, false);
emailInput = (EditText) forgotPasswordView.findViewById(R.id.email);
applyTheme(forgotPasswordView);
return forgotPasswordView;
} else {
throw new RuntimeException("Context cannot be null");
}
}
示例12: onCreateViewHolder
import android.view.ViewGroup; //导入依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View convertView = null;
ViewHolder holder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.item_mynote_details, parent, false);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.min_title = (TextView) convertView.findViewById(R.id.min_title);
holder.min_title_content = (TextView) convertView.findViewById(R.id.min_title_content);
holder.booke_content = (TextView) convertView.findViewById(R.id.booke_content);
holder.note_content = (TextView) convertView.findViewById(R.id.note_content);
holder.note_time = (TextView) convertView.findViewById(R.id.note_time);
holder.delete_note_icon = (ImageView) convertView.findViewById(R.id.delete_note_icon);
holder.detail_note_icon = (ImageView) convertView.findViewById(R.id.detail_note_icon);
return holder;
}
示例13: cleanup
import android.view.ViewGroup; //导入依赖的package包/类
/**
* Clean-up the resources attached to this object. This needs to be called when the zoomLayout is
* no longer used. A good example is from {@link android.view.View#onDetachedFromWindow()} or
* from {@link android.app.Activity#onDestroy()}. This is automatically called if you are using
* {@link DragPhotoView}.
*/
public void cleanup() {
if (null == zoomLayout) {
return; // cleanup already done
}
final ViewGroup view = zoomLayout.get();
if (null != view) {
// Remove the zoomLayout's reference to this
view.setOnTouchListener(null);
}
if (null != gestureDetector) {
gestureDetector = null;
}
// Finally, clear zoomLayout
zoomLayout = null;
}
示例14: getView
import android.view.ViewGroup; //导入依赖的package包/类
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = View.inflate(MQEmotionKeyboardLayout.this.getContext(), R.layout
.mq_item_emotion_keyboard, null);
}
ImageView iconIv = (ImageView) convertView;
if (position == getCount() - 1) {
iconIv.setImageResource(R.drawable.mq_emoji_delete);
iconIv.setVisibility(0);
} else {
String key = (String) this.mDatas.get(position);
if (TextUtils.isEmpty(key)) {
iconIv.setVisibility(4);
} else {
iconIv.setImageResource(MQEmotionUtil.getImgByName(key));
iconIv.setVisibility(0);
}
}
return convertView;
}
示例15: onCreateViewHolder
import android.view.ViewGroup; //导入依赖的package包/类
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background);
sSelectedBackgroundColor = parent.getResources().getColor(R.color.selected_background);
mDefaultCardImage = parent.getResources().getDrawable(R.drawable.default_background);
ImageCardView cardView = new ImageCardView(parent.getContext()) {
@Override
public void setSelected(boolean selected) {
updateCardBackgroundColor(this, selected);
super.setSelected(selected);
}
};
cardView.setFocusable(true);
cardView.setFocusableInTouchMode(true);
updateCardBackgroundColor(cardView, false);
return new ViewHolder(cardView);
}