Example usage for android.widget LinearLayout getChildAt

List of usage examples for android.widget LinearLayout getChildAt

Introduction

In this page you can find the example usage for android.widget LinearLayout getChildAt.

Prototype

public View getChildAt(int index) 

Source Link

Document

Returns the view at the specified position in the group.

Usage

From source file:com.github.tetravex_android.activity.HiScoreActivity.java

/**
 * Sets the page indicator dots at the bottom of the screen to indicate which page is displayed
 *
 * @param pageIndex the index of the page currently displayed
 *//*  w w w.  ja  v  a 2s . c o m*/
private void setIndicatorDots(int pageIndex) {
    // set the indicator dot for the correct page
    LinearLayout dotGroup = (LinearLayout) findViewById(R.id.hi_score_dot_ll);
    for (int i = 0; i < dotGroup.getChildCount(); i++) {
        ImageView view = (ImageView) dotGroup.getChildAt(i);
        String tagString = (String) view.getTag();
        int tagId = Integer.valueOf(tagString);

        if (tagId == pageIndex) {
            view.setImageResource(R.drawable.pager_dot_on);
        } else {
            view.setImageResource(R.drawable.pager_dot_off);
        }
    }
}

From source file:com.cmput301.recipebot.test.EditRecipeActivityTest.java

/**
 * Deletes all children from a linear layout
 *
 * @param layout/*from   w w w  . ja  v  a 2  s . c o m*/
 */
private void clearList(LinearLayout layout) {
    int child_count = layout.getChildCount();
    for (int i = 0; i < child_count; i++) {
        final CheckBox child = (CheckBox) layout.getChildAt(0);
        instrumentation.runOnMainSync(new Runnable() {
            @Override
            public void run() {
                child.setChecked(true);
            }
        });
        instrumentation.waitForIdleSync();
        final View delete = activity.findViewById(R.id.menu_delete_item_from_list);
        instrumentation.runOnMainSync(new Runnable() {
            @Override
            public void run() {
                delete.performClick();
            }
        });
        instrumentation.waitForIdleSync();
    }
    assertThat(layout).hasChildCount(0);
    Spoon.screenshot(activity, "cleared");
}

From source file:com.sonymobile.androidapp.gridcomputing.fragments.WizardMainFragment.java

/**
 * Update page indicator to match current page.
 *
 * @param page current page.//from ww w  .j a v a  2 s . co m
 */
private void updatePageIndicator(final int page) {
    // update page indicator.
    LinearLayout container = (LinearLayout) getActivity().findViewById(R.id.wizard_page_indicator_container);

    for (int i = 0; i < NUM_PAGES; i++) {
        final View view = container.getChildAt(i);
        view.setSelected(false);
        if (i == page) {
            view.setSelected(true);
        }
    }
}

From source file:mobisocial.musubi.objects.WebAppObj.java

@Override
public void render(Context context, View view, DbObjCursor obj, boolean allowInteractions) throws Exception {
    LinearLayout frame = (LinearLayout) view;

    TextView tv = (TextView) ((ViewGroup) frame.getChildAt(0)).getChildAt(1);
    tv.setText("Webapp " + getAppName(obj));

    if (allowInteractions) {
        Button b = (Button) ((ViewGroup) frame.getChildAt(1)).getChildAt(0);
        long objId = obj.objId;
        b.setTag(objId);//from  ww  w .  j  a  v a 2 s.com

        b = (Button) ((ViewGroup) ((ViewGroup) view).getChildAt(1)).getChildAt(1);
        b.setTag(objId);
        AppManager am = new AppManager(App.getDatabaseSource(context));
        MApp lookup = am.lookupAppByAppId(getAppId(obj));
        //deleted ones can be readded
        //ensure app may have put it in the table without a url;
        if (lookup == null || lookup.deleted_ == true || lookup.webAppUrl_ == null) {
            b.setText("Add");
            b.setEnabled(true);
        } else {
            b.setText("Added");
            b.setEnabled(false);
        }
    }
}

From source file:com.flan.stock.activity.WelcomeActivity.java

private void initDot() {

    LinearLayout ll = (LinearLayout) this.findViewById(R.id.lay_dot);

    int size = viewPager.getAdapter().getCount();
    dots = new ImageView[size];

    for (int i = 0; i < dots.length; i++) {

        dots[i] = (ImageView) ll.getChildAt(i);
        dots[i].setTag(i);/* w w w.  j a v  a2  s .com*/
        //dots[i].setEnabled(true);
        //?
        dots[i].setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                int position = (int) v.getTag(); //??

                setCurrentDot(position);
                setCurrentView(position);
            }
        });
    }

    dots[currentIndex].setEnabled(false); //??
}

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 w ww  .jav  a2 s  .c o m
        tv.setBackgroundResource(R.drawable.vpi__tab_unselected_holo);

    }
}

From source file:org.kevoree.platform.android.boot.view.ManagerUI.java

@Override
public void removeView(View view) {

    if (view == null) {
        return;/*from  w  w w .jav a2  s  .c o m*/
    }

    Log.i("Request remove view", "");
    LinkedList<ActionBar.Tab> newtabs = new LinkedList<ActionBar.Tab>();
    for (ActionBar.Tab tab : tabs) {
        LinearLayout tabLayout = (LinearLayout) tab.getTag();
        int childcount = tabLayout.getChildCount();
        for (int i = 0; i < childcount; i++) {
            View v = tabLayout.getChildAt(i);
            if (v != null) {
                if (v.equals(view)) {
                    tabLayout.removeView(view);
                }
            }
        }
        Log.i("Remove view " + tab.getText(), " " + ((LinearLayout) tab.getTag()).getChildCount());
        if (((LinearLayout) tab.getTag()).getChildCount() == 0) {
            if (tab.getPosition() == selectedTab) {
                selectedTab = ktab;
            }
            ctx.getSupportActionBar().removeTab(tab);
        } else {
            newtabs.add(tab);
        }
    }
    tabs.clear();
    tabs.addAll(newtabs);
    notifyObservers(this);
}

From source file:org.exoplatform.mobile.tests.SocialTabsActivityTest.java

public void verifyDefaultLayout() {
    create();//from   w  w w.j  a  v  a 2  s. co  m
    init();

    assertNotNull("Button should exist at pos 0", actionBar.getItem(0)); // Refresh
    assertNotNull("Button should exist at pos 1", actionBar.getItem(1)); // Compose
    // ActionBar.getItem() returns null when there is no item at the given
    // position
    assertNull("Button should not exist at pos 2", actionBar.getItem(2));

    assertThat(pages.getAdapter()).hasCount(4); // Should have 4 pages
    assertThat("Default tab should be All Updates", pages.getCurrentItem(),
            equalTo(SocialTabsActivity.ALL_UPDATES));

    LinearLayout tabsLayout = (LinearLayout) tabs.getChildAt(0);
    // check each tab's title
    String[] tabsTitle = activity.getResources().getStringArray(R.array.SocialTabs);
    assertThat((TextView) tabsLayout.getChildAt(SocialTabsActivity.ALL_UPDATES))
            .containsText(tabsTitle[SocialTabsActivity.ALL_UPDATES]);
    assertThat((TextView) tabsLayout.getChildAt(SocialTabsActivity.MY_CONNECTIONS))
            .containsText(tabsTitle[SocialTabsActivity.MY_CONNECTIONS]);
    assertThat((TextView) tabsLayout.getChildAt(SocialTabsActivity.MY_SPACES))
            .containsText(tabsTitle[SocialTabsActivity.MY_SPACES]);
    assertThat((TextView) tabsLayout.getChildAt(SocialTabsActivity.MY_STATUS))
            .containsText(tabsTitle[SocialTabsActivity.MY_STATUS]);

}

From source file:org.kevoree.platform.android.boot.view.ManagerUI.java

/**
 * this method is charge of restoring views during a rotation of the screen
 *///  w w  w . j a  v a  2s.  c  o  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.flan.stock.activity.HomeActivity.java

private void initDot() {

    LinearLayout ll = (LinearLayout) this.findViewById(R.id.lay_dot);

    int size = viewPager.getAdapter().getCount();
    dots = new ImageView[size];

    for (int i = 0; i < dots.length; i++) {

        dots[i] = (ImageView) ll.getChildAt(i);
        dots[i].setTag(i);//from ww  w.j a v a  2 s.  c  o m
        //dots[i].setEnabled(true);
        //?
        dots[i].setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                int position = (int) v.getTag(); //??

                setCurrentDot(position);
                setCurrentView(position);
            }
        });
    }

    dots[navCurrentIndex].setEnabled(false); //??
}