List of usage examples for android.widget LinearLayout getChildCount
public int getChildCount()
From source file:org.kevoree.platform.android.boot.view.ManagerUI.java
/** * this method is charge of restoring views during a rotation of the screen *//*from www.j a v a 2 s . co m*/ public void restoreViews(FragmentActivity newctx) { if (ctx.getSupportActionBar().getTabAt(selectedTab) == null) { selectedTab = ktab; } ctx.getSupportActionBar().removeAllTabs(); newctx.getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ctx = newctx; LinkedList<ActionBar.Tab> backup = new LinkedList<ActionBar.Tab>(); backup.addAll(tabs); tabs.clear(); for (ActionBar.Tab tab : backup) { Log.i(TAG, "Restore " + tab.getText()); // if exist remove parent View contentView = (View) tab.getTag(); if (contentView.getParent() != null) { ((ViewGroup) contentView.getParent()).removeView(contentView); } LinearLayout tabLayout = (LinearLayout) contentView; int childcount = tabLayout.getChildCount(); for (int i = 0; i < childcount; i++) { View v = tabLayout.getChildAt(i); if (v != null) { // remove link to linearlayout if (v.getParent() != null) { ((ViewGroup) v.getParent()).removeView(v); } addToGroup(tab.getText().toString(), v); } } } try { ctx.getSupportActionBar().setSelectedNavigationItem(selectedTab); } catch (Exception e) { // ignore } }
From source file:com.huaop2p.yqs.widget.TabPageIndicator.java
public void clearHeadTextColor(int colorId) { LinearLayout layout = getHeadView(); for (int i = 0; i < layout.getChildCount(); i++) { TextView tv = (TextView) layout.getChildAt(i); tv.setTextColor(getResources().getColor(colorId)); tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimensionPixelSize(R.dimen.text_content_size)); AutoUtils.autoTextSize(tv);/*from ww w . j a v a 2 s. c o m*/ tv.setBackgroundResource(R.drawable.vpi__tab_unselected_holo); } }
From source file:com.irccloud.android.activity.ShareChooserActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); countdownTimer = new Timer("share-chooser-countdown-timer"); setTheme(ColorScheme.getDialogTheme(ColorScheme.getUserTheme())); ColorScheme.getInstance().setThemeFromContext(this, ColorScheme.getUserTheme()); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.splash_logo); setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, ColorScheme.getInstance().navBarColor)); getWindow().setStatusBarColor(ColorScheme.getInstance().statusBarColor); getWindow().setNavigationBarColor(getResources().getColor(android.R.color.black)); }/*from ww w . j av a 2 s .com*/ getWindow().requestFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_share_chooser); connecting = findViewById(R.id.connecting); errorMsg = findViewById(R.id.errorMsg); connectingMsg = findViewById(R.id.connectingMsg); progressBar = findViewById(R.id.connectingProgress); BuffersListFragment f = (BuffersListFragment) getSupportFragmentManager() .findFragmentById(R.id.BuffersList); f.readOnly = true; f.setSelectedBid(-2); buffersList = f.getView(); buffersList.setVisibility(View.GONE); Typeface SourceSansProRegular = ResourcesCompat .getFont(IRCCloudApplication.getInstance().getApplicationContext(), R.font.sourcesansproregular); LinearLayout IRCCloud = findViewById(R.id.IRCCloud); for (int i = 0; i < IRCCloud.getChildCount(); i++) { View v = IRCCloud.getChildAt(i); if (v instanceof TextView) { ((TextView) v).setTypeface(SourceSansProRegular); } } conn = NetworkConnection.getInstance(); conn.addHandler(this); }
From source file:ca.xef6.firecamp.ProfilePictureSampleFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { View fragmentView = inflater.inflate(R.layout.fragment_profile_picture_sample, parent, false); randomGenerator = new Random((new Date()).getTime()); profilePic = (ProfilePictureView) fragmentView.findViewById(R.id.profilepic); smallerButton = (Button) fragmentView.findViewById(R.id.smallerButton); largerButton = (Button) fragmentView.findViewById(R.id.largerButton); sizeLabel = (TextView) fragmentView.findViewById(R.id.sizeLabel); presetSizeView = fragmentView.findViewById(R.id.presetSizeView); customSizeView = (SeekBar) fragmentView.findViewById(R.id.customSizeView); cropToggle = (CheckBox) fragmentView.findViewById(R.id.squareCropToggle); LinearLayout container = (LinearLayout) fragmentView.findViewById(R.id.userbuttoncontainer); int numChildren = container.getChildCount(); for (int i = 0; i < numChildren; i++) { View childView = container.getChildAt(i); Object tag = childView.getTag(); if (childView instanceof Button) { setupUserButton((Button) childView); if (i == 0) { // Initialize the image to the first user firstUserId = tag.toString(); }/*from ww w .ja va 2 s . c om*/ } } cropToggle.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton checkbox, boolean checked) { profilePic.setCropped(checked); } }); final Button sizeToggle = (Button) fragmentView.findViewById(R.id.sizeToggle); sizeToggle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (pictureSizeType != ProfilePictureView.CUSTOM) { sizeToggle.setText("preset size button text"); switchToCustomSize(); } else { sizeToggle.setText("custom size button text"); switchToPresetSize(ProfilePictureView.LARGE); } } }); smallerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { switch (profilePic.getPresetSize()) { case ProfilePictureView.LARGE: switchToPresetSize(ProfilePictureView.NORMAL); break; case ProfilePictureView.NORMAL: switchToPresetSize(ProfilePictureView.SMALL); break; } } }); largerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { switch (profilePic.getPresetSize()) { case ProfilePictureView.NORMAL: switchToPresetSize(ProfilePictureView.LARGE); break; case ProfilePictureView.SMALL: switchToPresetSize(ProfilePictureView.NORMAL); break; } } }); // We will fetch a new image for each change in the SeekBar. So keeping the count low // to prevent too much network chatter. SeekBar reports 0-max, so we will get max+1 // notifications of change. customSizeView.setMax(MAX_CUSTOM_SIZES); customSizeView.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { updateProfilePicForCustomSizeIncrement(i); } @Override public void onStartTrackingTouch(SeekBar seekBar) { // NO-OP } @Override public void onStopTrackingTouch(SeekBar seekBar) { // NO-OP } }); restoreState(savedInstanceState); return fragmentView; }
From source file:com.facebook.samples.profilepicture.ProfilePictureSampleFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { View fragmentView = inflater.inflate(R.layout.fragment_profile_picture_sample, parent, false); randomGenerator = new Random((new Date()).getTime()); profilePic = (ProfilePictureView) fragmentView.findViewById(R.id.profilepic); smallerButton = (Button) fragmentView.findViewById(R.id.smallerButton); largerButton = (Button) fragmentView.findViewById(R.id.largerButton); sizeLabel = (TextView) fragmentView.findViewById(R.id.sizeLabel); presetSizeView = fragmentView.findViewById(R.id.presetSizeView); customSizeView = (SeekBar) fragmentView.findViewById(R.id.customSizeView); cropToggle = (CheckBox) fragmentView.findViewById(R.id.squareCropToggle); LinearLayout container = (LinearLayout) fragmentView.findViewById(R.id.userbuttoncontainer); int numChildren = container.getChildCount(); for (int i = 0; i < numChildren; i++) { View childView = container.getChildAt(i); Object tag = childView.getTag(); if (childView instanceof Button) { setupUserButton((Button) childView); if (i == 0) { // Initialize the image to the first user firstUserId = tag.toString(); }//www . j av a 2s .c o m } } cropToggle.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton checkbox, boolean checked) { profilePic.setCropped(checked); } }); final Button sizeToggle = (Button) fragmentView.findViewById(R.id.sizeToggle); sizeToggle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (pictureSizeType != ProfilePictureView.CUSTOM) { sizeToggle.setText(R.string.preset_size_button_text); switchToCustomSize(); } else { sizeToggle.setText(R.string.custom_size_button_text); switchToPresetSize(ProfilePictureView.LARGE); } } }); smallerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { switch (profilePic.getPresetSize()) { case ProfilePictureView.LARGE: switchToPresetSize(ProfilePictureView.NORMAL); break; case ProfilePictureView.NORMAL: switchToPresetSize(ProfilePictureView.SMALL); break; } } }); largerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { switch (profilePic.getPresetSize()) { case ProfilePictureView.NORMAL: switchToPresetSize(ProfilePictureView.LARGE); break; case ProfilePictureView.SMALL: switchToPresetSize(ProfilePictureView.NORMAL); break; } } }); // We will fetch a new image for each change in the SeekBar. So keeping the count low // to prevent too much network chatter. SeekBar reports 0-max, so we will get max+1 // notifications of change. customSizeView.setMax(MAX_CUSTOM_SIZES); customSizeView.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { updateProfilePicForCustomSizeIncrement(i); } @Override public void onStartTrackingTouch(SeekBar seekBar) { // NO-OP } @Override public void onStopTrackingTouch(SeekBar seekBar) { // NO-OP } }); restoreState(savedInstanceState); return fragmentView; }
From source file:org.mifos.androidclient.main.AccountDetailsActivity.java
private void updateContent(AbstractAccountDetails details) { if (details != null) { mDetails = details;/*from w w w . j av a2s.co m*/ ViewBuilderFactory factory = new ViewBuilderFactory(this); AccountDetailsViewBuilder builder = factory.createAccountDetailsViewBuilder(details); LinearLayout tabContent = (LinearLayout) findViewById(R.id.account_overview); if (tabContent.getChildCount() > 0) { tabContent.removeAllViews(); } tabContent.addView(builder.buildOverviewView()); tabContent = (LinearLayout) findViewById(R.id.account_transaction); if (tabContent.getChildCount() > 0) { tabContent.removeAllViews(); } tabContent.addView(builder.buildTransactionView()); tabContent = (LinearLayout) findViewById(R.id.account_details); if (tabContent.getChildCount() > 0) { tabContent.removeAllViews(); } tabContent.addView(builder.buildDetailsView()); if (details.getClass() == SavingsAccountDetails.class) { if (((SavingsAccountDetails) details).getDepositTypeName() .equals(SavingsAccountDetails.MANDATORY_DEPOSIT)) { Button depositDueButton = (Button) findViewById(R.id.view_depositDueDetails_button); depositDueButton.setVisibility(View.VISIBLE); } } } }
From source file:app.jorge.mobile.com.transportalert.ScrollingActivity.java
@Override public void onRefresh() { mSwipeRefreshLayout.setRefreshing(false); LinearLayout item = (LinearLayout) findViewById(R.id.rv); if (item.getChildCount() > 0) { item.removeAllViews();/*from www.j a va 2 s . c o m*/ } addAllCards(item); // asynchronous Retrofit retrofit = new Retrofit.Builder().baseUrl(getString(R.string.url_tfl_api)) .addConverterFactory(GsonConverterFactory.create()).build(); TaskService taskService = retrofit.create(TaskService.class); Call<List<StatusLine>> call = taskService.login(getString(R.string.app_id), getString(R.string.app_key)); call.enqueue(this); }
From source file:asu.edu.msse.gpeddabu.moviedescriptions.MovieListAdapter.java
@Override public boolean onTouch(View v, MotionEvent event) { // when the user touches an item, onTouch is called for action down and again for action up // we only want to do something on one of those actions. event tells us which action. if (event.getAction() == MotionEvent.ACTION_DOWN) { // onTouch is passed the textview's parent view, a linearlayout - what we set the // event on. Look at its children to find the textview if (v instanceof android.widget.LinearLayout) { android.widget.LinearLayout layView = (android.widget.LinearLayout) v; // the layout (from list_item.xml should only have one child, but, here's how // you find the children of a layout or other view group. for (int i = 0; i <= layView.getChildCount(); i++) { if (layView.getChildAt(i) instanceof TextView) { // keep track of TV stuff was most recently touched to un-highlighted if (currSelection != null) { currSelection.setBackgroundColor(parent.getResources().getColor(R.color.light_blue)); }/* w ww .j a v a2s. c o m*/ TextView tmp = ((TextView) layView.getChildAt(i)); currSelection = tmp; parent.setSelectedStuff(tmp.getText().toString()); // create an intent (in the name of the parent activity) to start the WebViewActivity // pass the web view activity two strings: the url and the name of the selected item. // expect the WebViewActivity to return a result, which will be picked up in the // requesting activity -- MainActivity. Intent movieDetails = new Intent(parent, MovieDetails.class); // movieDetails.putExtra("MovieLibrary",(parent.movieLibrary)); movieDetails.putExtra("movieName", ((TextView) layView.getChildAt(i)).getText().toString()); // try { // movieDetails.putExtra("genreName", getGenre(((TextView) layView.getChildAt(i)).getText().toString())); // } catch (JSONException e) { // e.printStackTrace(); // }; parent.startActivity(movieDetails); } } } // code below should never executes. onTouch is called for textview's linearlayout parent if (v instanceof TextView) { android.util.Log.d(this.getClass().getSimpleName(), "in onTouch called for: " + ((TextView) v).getText()); } } return true; }
From source file:com.itude.mobile.mobbl.core.view.components.tabbar.MBDefaultActionBarBuilder.java
protected void setSearchImage(Drawable image, LinearLayout linearLayout) { ImageView searchViewIcon = null; for (int i = 0; i < linearLayout.getChildCount(); i++) { View view = linearLayout.getChildAt(i); if (view instanceof ImageView) { searchViewIcon = (ImageView) view; break; }//from www . java 2 s. c o m } searchViewIcon.setImageDrawable(image); }
From source file:com.flowzr.activity.RecurActivity.java
private View selectInLayout(LinearLayout layout, Object tag) { View selected = null;//from w w w.j a v a2s . c om int count = layout.getChildCount(); for (int i = 0; i < count; i++) { View v = layout.getChildAt(i); if (tag == v.getTag()) { selected = v; } else { v.setVisibility(View.GONE); } } if (selected != null) { selected.setVisibility(View.VISIBLE); } return selected; }