本文整理匯總了Java中android.support.constraint.ConstraintLayout類的典型用法代碼示例。如果您正苦於以下問題:Java ConstraintLayout類的具體用法?Java ConstraintLayout怎麽用?Java ConstraintLayout使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ConstraintLayout類屬於android.support.constraint包,在下文中一共展示了ConstraintLayout類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addPlayer
import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
public void addPlayer(View view) {
EditText newNameText = (EditText) findViewById(R.id.newNameText);
String newName = newNameText.getText().toString();
newNameText.setText("");
if (newName.length() > 0 && playerNum < maxNum) {
shiftPlayersDown();
TextView playerName = (TextView) findViewById(playerTextIds.get(0));
playerName.setText(newName);
ConstraintLayout playerLayout = (ConstraintLayout) findViewById(playerLayoutIds.get(playerNum));
playerLayout.setVisibility(View.VISIBLE);
playerNum++;
}
}
示例2: removePlayer
import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
public void removePlayer(View view) {
int playerIndex = -1;
for(int i = 0; i < playerNum; i++) {
if (view.getId() == playerButtonIds.get(i)) {
playerIndex = i;
break;
}
}
if (playerIndex >= 0) {
shiftPlayersUp(playerIndex);
playerNum--;
ConstraintLayout playerLayout = (ConstraintLayout) findViewById(playerLayoutIds.get(playerNum));
playerLayout.setVisibility(View.INVISIBLE);
}
}
示例3: initViews
import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
/**
* This method will create the view object from XLM to Java and instanciate objects. Used when the user reboots it's device
*
*/
private void initViews() {
//init graphical element
txtViewGlucose=(TextView)view.findViewById(R.id.txtView_GlucoseValue);
txtViewPulse=(TextView)view.findViewById(R.id.txtView_pulseValue);
txtViewSystol=(TextView)view.findViewById(R.id.txtView_systolValue);
txtViewDiastol=(TextView)view.findViewById(R.id.txtView_DiastolValue);
txtViewSteps=(TextView)view.findViewById(R.id.txtView_stepValue);
txtViewWeight=(TextView)view.findViewById(R.id.txtView_weightValue);
//create the bar object
barPulse=(ConstraintLayout)view.findViewById(R.id.bar_pulse);
barGlucose=(ConstraintLayout)view.findViewById(R.id.bar_glucose);
barSystol=(ConstraintLayout)view.findViewById(R.id.bar_sys);
barDiastol=(ConstraintLayout)view.findViewById(R.id.bar_dias);
barStep=(ConstraintLayout)view.findViewById(R.id.bar_step);
barWeight=(ConstraintLayout)view.findViewById(R.id.bar_weight);
imgGlucose=(ImageButton) view.findViewById(R.id.img_severity_glucose);
imgPulse=(ImageButton) view.findViewById(R.id.img_severity_pulse);
imgPressure=(ImageButton)view.findViewById(R.id.img_severity_pressure);
imgStep=(ImageButton)view.findViewById(R.id.img_severity_step);
imgWeight=(ImageButton)view.findViewById(R.id.img_severity_weight);
}
示例4: onDoubleTap
import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
@Override
public boolean onDoubleTap(MotionEvent event) {
Log.d(DEBUG_TAG, "onDoubleTap: " + event.toString());
ConstraintLayout bimg = (ConstraintLayout) findViewById(R.id.layout);
String background = String.valueOf(bimg.getTag());
if (background.equals("img")) {
bimg.setBackgroundResource(R.drawable.wallp);
bimg.setTag("wallp");
} else {
if (background.equals("wallp")) {
bimg.setBackgroundResource(R.drawable.fond);
bimg.setTag("fond");
} else {
if (background.equals("fond")) {
bimg.setBackgroundResource(R.drawable.img);
bimg.setTag("img");
}
}
}
return true;
}
示例5: onCreate
import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.constraintset_example_main);
mRootLayout = (ConstraintLayout) findViewById(R.id.activity_constraintset_example);
// Note that this can also be achieved by calling
// `mConstraintSetNormal.load(this, R.layout.constraintset_example_main);`
// Since we already have an inflated ConstraintLayout in `mRootLayout`, clone() is
// faster and considered the best practice.
mConstraintSetNormal.clone(mRootLayout);
// Load the constraints from the layout where ImageView is enlarged.
mConstraintSetBig.load(this, R.layout.constraintset_example_big);
if (savedInstanceState != null) {
boolean previous = savedInstanceState.getBoolean(SHOW_BIG_IMAGE);
if (previous != mShowBigImage) {
mShowBigImage = previous;
applyConfig();
}
}
}
開發者ID:googlesamples,項目名稱:android-ConstraintLayoutExamples,代碼行數:23,代碼來源:ConstraintSetExampleActivity.java
示例6: reloadImages
import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
private void reloadImages( final ConstraintLayout fab, final DatabaseReference ref, final String uid ) {
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
clearPicList();
updatePicList( snapshot, uid );
gridAdapter.notifyDataSetChanged();
gridView.invalidateViews();
ref.removeEventListener(this);
}
@Override
public void onCancelled(DatabaseError databaseError) {
ref.removeEventListener(this);
}
});
}
});
}
示例7: DataViewHolder
import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
DataViewHolder(final View itemView) {
super(itemView);
textView = (TextView) itemView.findViewById(tv);
imageView = (ImageView) itemView.findViewById(R.id.iv);
packageInfo = (TextView) itemView.findViewById(R.id.packageName);
share = (Button) itemView.findViewById(R.id.shareApk);
uninstall = (Button) itemView.findViewById(R.id.uninstallApk);
extract = (Button) itemView.findViewById(R.id.extractApk);
expandableView = (ConstraintLayout) itemView.findViewById(R.id.expandableView);
share.setOnClickListener(this);
uninstall.setOnClickListener(this);
extract.setOnClickListener(this);
}
示例8: setContentView
import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
private void setContentView() {
int _padding = NumberUtil.get_px(getContext(), 15);
setPadding(_padding, _padding, _padding, _padding);
inflate(getContext(), R.layout.widget_sdcard_percent, this);
_line = (ConstraintLayout) findViewById(R.id.block_percent);
_text_system = (TextView) findViewById(R.id.textView_count_system);
_text_blank = (TextView) findViewById(R.id.textView_count_blank);
_text_file = (TextView) findViewById(R.id.textView_count_file);
_text_rubbish = (TextView) findViewById(R.id.textView_count_rubbish);
for (int _temp_i = 0; _temp_i < _line.getChildCount() && _line.getChildAt(_temp_i).getId() == -1; _temp_i++) {
_line.getChildAt(_temp_i).setId(_temp_i);
}
_set_line.clone(_line);
}
示例9: bind
import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
public void bind(final Item item) {
mTextLabel.setText(item.getLabel());
ConstraintLayout.LayoutParams layoutParamsTextLabel = (ConstraintLayout.LayoutParams) mTextLabel.getLayoutParams();
if (item.getPercent() > LABEL_POSITION_CHANGE_PERCENT) {
// move label above guideline
layoutParamsTextLabel.bottomToTop = mGuidelineTop.getId();
layoutParamsTextLabel.topToTop = -1;
layoutParamsTextLabel.bottomMargin = mLabelMargin;
layoutParamsTextLabel.topMargin = 0;
} else {
// move label below guideline
layoutParamsTextLabel.topToTop = mGuidelineTop.getId();
layoutParamsTextLabel.bottomToTop = -1;
layoutParamsTextLabel.bottomMargin = 0;
layoutParamsTextLabel.topMargin = mLabelMargin;
}
mTextLabel.setLayoutParams(layoutParamsTextLabel);
ConstraintLayout.LayoutParams layoutParamsGuideline = (ConstraintLayout.LayoutParams) mGuidelineTop.getLayoutParams();
layoutParamsGuideline.guidePercent = item.getPercent();
mGuidelineTop.setLayoutParams(layoutParamsGuideline);
}
示例10: ViewHolderItem
import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
public ViewHolderItem(View itemView) {
super(itemView);
itemView.setOnClickListener(this);
// itemDescription = (TextView) itemView.findViewById(R.id.itemDescription);
itemName = (TextView) itemView.findViewById(R.id.itemName);
itemImage = (ImageView) itemView.findViewById(R.id.itemImage);
priceRange = (TextView) itemView.findViewById(R.id.price_range);
priceAverage = (TextView) itemView.findViewById(R.id.price_average);
shopCount = (TextView) itemView.findViewById(R.id.shop_count);
itemsListItem = (ConstraintLayout) itemView.findViewById(R.id.items_list_item);
itemRating = (TextView) itemView.findViewById(R.id.item_rating);
ratingCount = (TextView) itemView.findViewById(R.id.rating_count);
itemsListItem.setOnClickListener(this);
itemImage.setOnClickListener(this);
}
示例11: ViewHolder
import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
public ViewHolder(View itemView) {
super(itemView);
itemView.setOnClickListener(this);
// itemDescription = (TextView) itemView.findViewById(R.id.itemDescription);
itemName = (TextView) itemView.findViewById(R.id.itemName);
itemImage = (ImageView) itemView.findViewById(R.id.itemImage);
priceRange = (TextView) itemView.findViewById(R.id.price_range);
priceAverage = (TextView) itemView.findViewById(R.id.price_average);
shopCount = (TextView) itemView.findViewById(R.id.shop_count);
itemsListItem = (ConstraintLayout) itemView.findViewById(R.id.items_list_item);
itemRating = (TextView) itemView.findViewById(R.id.item_rating);
ratingCount = (TextView) itemView.findViewById(R.id.rating_count);
itemsListItem.setOnClickListener(this);
itemImage.setOnClickListener(this);
}
開發者ID:SumeetMoray,項目名稱:Nearby-Shops-End-User-Android-app,代碼行數:20,代碼來源:AdapterItemHorizontalScreen.java
示例12: onCreateViewHolder
import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
ViewHolder viewHolder = null;
Context context = parent.getContext();
switch (viewType) {
case TYPE_TOPIC:
viewHolder = TopicViewHolder.makeHolder(parent, mContentListener, mNodeListener, mAvatarListener);
break;
case TYPE_COMMENT:
final CommentView view = new CommentView(context);
view.setLayoutParams(
new ConstraintLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
viewHolder = new CommentViewHolder(view, mCommentListener);
}
return viewHolder;
}
示例13: onResume
import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
@Override
public void onResume() {
super.onResume();
if (getUserVisibleHint()) {
if (getView() != null) {
swipeRefreshLayout = getView().findViewById(R.id.swipe_refresh_layout);
}
}
if (swipeRefreshLayout != null) {
swipeRefreshLayout.setOnRefreshListener(this);
}
AppBarLayout appBar = getActivity().findViewById(R.id.appbar);
if (appBar != null) {
Guideline guideTopInfo = getView().findViewById(R.id.guideline);
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) guideTopInfo.getLayoutParams();
params.guidePercent = .45f;
guideTopInfo.setLayoutParams(params);
}
refreshHandler.post(refreshRunnable);
}
示例14: onCreateView
import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
// The last two arguments ensure LayoutParams are inflated
// properly.
View rootView = inflater.inflate(R.layout.fragment_greetings, container, false);
ok = (BRButton) rootView.findViewById(R.id.ok);
mainLayout = (ConstraintLayout) rootView.findViewById(R.id.signal_layout);
background = (RelativeLayout) rootView.findViewById(R.id.layout);
ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().onBackPressed();
}
});
return rootView;
}
示例15: bind
import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
@Override
public void bind(ConstraintLayout view)
{
ButterKnife.bind(this, view);
tvReleaseName.setText(releaseName);
tvDatePosted.setText("Listed: " + dateFormatter.formatIsoDate(datePosted));
lytListing.setOnClickListener(onClickListener);
}