Search in sources :

Example 31 with TabWidget

use of android.widget.TabWidget in project pictureapp by EyeSeeTea.

the class DashboardActivity method addTagToLastTab.

private void addTagToLastTab(String tabName) {
    TabWidget tabWidget = tabHost.getTabWidget();
    int numTabs = tabWidget.getTabCount();
    ViewGroup tabIndicator = (ViewGroup) tabWidget.getChildTabViewAt(numTabs - 1);
    ImageView imageView = (ImageView) tabIndicator.getChildAt(0);
    imageView.setTag(tabName);
    TextView textView = (TextView) tabIndicator.getChildAt(1);
    textView.setGravity(Gravity.CENTER);
    textView.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
    textView.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
}
Also used : ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) ImageView(android.widget.ImageView) TabWidget(android.widget.TabWidget)

Example 32 with TabWidget

use of android.widget.TabWidget in project iNaturalistAndroid by inaturalist.

the class GuidesActivity method refreshTabs.

private void refreshTabs(int pos) {
    TabWidget tabWidget = mTabHost.getTabWidget();
    for (int i = 0; i < 3; i++) {
        tabWidget.getChildAt(i).findViewById(R.id.bottom_line).setVisibility(View.GONE);
        ((TextView) tabWidget.getChildAt(i).findViewById(R.id.tab_title)).setTextColor(Color.parseColor("#84000000"));
    }
    tabWidget.getChildAt(pos).findViewById(R.id.bottom_line).setVisibility(View.VISIBLE);
    ((TextView) tabWidget.getChildAt(pos).findViewById(R.id.tab_title)).setTextColor(Color.parseColor("#000000"));
}
Also used : TextView(android.widget.TextView) TabWidget(android.widget.TabWidget) SuppressLint(android.annotation.SuppressLint)

Example 33 with TabWidget

use of android.widget.TabWidget in project iNaturalistAndroid by inaturalist.

the class UserProfile method refreshViewType.

private void refreshViewType() {
    mObservationsContainer.setVisibility(View.GONE);
    mSpeciesContainer.setVisibility(View.GONE);
    mIdentificationsContainer.setVisibility(View.GONE);
    TabWidget tabWidget = mTabHost.getTabWidget();
    for (int i = 0; i < tabWidget.getChildCount(); i++) {
        View tab = tabWidget.getChildAt(i);
        TextView tabNameText = (TextView) tab.findViewById(R.id.tab_name);
        View bottomLine = tab.findViewById(R.id.bottom_line);
        tabNameText.setTypeface(null, Typeface.NORMAL);
        tabNameText.setTextColor(Color.parseColor("#ACACAC"));
        bottomLine.setVisibility(View.GONE);
    }
    int selectedTab = 0;
    if (mViewType.equals(VIEW_TYPE_OBSERVATIONS)) {
        selectedTab = 0;
        mObservationsContainer.setVisibility(View.VISIBLE);
    } else if (mViewType.equals(VIEW_TYPE_SPECIES)) {
        selectedTab = 1;
        mSpeciesContainer.setVisibility(View.VISIBLE);
    } else if (mViewType.equals(VIEW_TYPE_IDENTIFICATIONS)) {
        selectedTab = 2;
        mIdentificationsContainer.setVisibility(View.VISIBLE);
    }
    mTabHost.setCurrentTab(selectedTab);
    View tab = tabWidget.getChildAt(selectedTab);
    TextView tabNameText = (TextView) tab.findViewById(R.id.tab_name);
    View bottomLine = tab.findViewById(R.id.bottom_line);
    tabNameText.setTypeface(null, Typeface.BOLD);
    tabNameText.setTextColor(Color.parseColor("#000000"));
    bottomLine.setVisibility(View.VISIBLE);
}
Also used : TextView(android.widget.TextView) TabWidget(android.widget.TabWidget) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 34 with TabWidget

use of android.widget.TabWidget in project iNaturalistAndroid by inaturalist.

the class UserProfile method refreshViewState.

private void refreshViewState() {
    TabWidget tabWidget = mTabHost.getTabWidget();
    DecimalFormat formatter = new DecimalFormat("#,###,###");
    if (mObservations == null) {
        ((TextView) tabWidget.getChildAt(0).findViewById(R.id.count)).setVisibility(View.GONE);
        ((ProgressBar) tabWidget.getChildAt(0).findViewById(R.id.loading)).setVisibility(View.VISIBLE);
        mLoadingObservationsList.setVisibility(View.VISIBLE);
        mObservationsList.setVisibility(View.GONE);
        mObservationsListEmpty.setVisibility(View.GONE);
    } else {
        ((TextView) tabWidget.getChildAt(0).findViewById(R.id.count)).setVisibility(View.VISIBLE);
        ((ProgressBar) tabWidget.getChildAt(0).findViewById(R.id.loading)).setVisibility(View.GONE);
        ((TextView) tabWidget.getChildAt(0).findViewById(R.id.count)).setText(formatter.format(mTotalObservations));
        mLoadingObservationsList.setVisibility(View.GONE);
        if (mObservations.size() == 0) {
            mObservationsListEmpty.setVisibility(View.VISIBLE);
        } else {
            mObservationsListEmpty.setVisibility(View.GONE);
        }
        if (mObservationsList.getAdapter() == null) {
            mObservationsListAdapter = new UserObservationAdapter(UserProfile.this, mObservations);
            mObservationsList.setAdapter(mObservationsListAdapter);
        }
        mObservationsList.setVisibility(View.VISIBLE);
    }
    if (mSpecies == null) {
        ((TextView) tabWidget.getChildAt(1).findViewById(R.id.count)).setVisibility(View.GONE);
        ((ProgressBar) tabWidget.getChildAt(1).findViewById(R.id.loading)).setVisibility(View.VISIBLE);
        mLoadingSpeciesList.setVisibility(View.VISIBLE);
        mSpeciesListEmpty.setVisibility(View.GONE);
        mSpeciesList.setVisibility(View.GONE);
    } else {
        ((TextView) tabWidget.getChildAt(1).findViewById(R.id.count)).setVisibility(View.VISIBLE);
        ((ProgressBar) tabWidget.getChildAt(1).findViewById(R.id.loading)).setVisibility(View.GONE);
        ((TextView) tabWidget.getChildAt(1).findViewById(R.id.count)).setText(formatter.format(mTotalSpecies));
        mLoadingSpeciesList.setVisibility(View.GONE);
        if (mSpecies.size() == 0) {
            mSpeciesListEmpty.setVisibility(View.VISIBLE);
        } else {
            mSpeciesListEmpty.setVisibility(View.GONE);
        }
        if (mSpeciesList.getAdapter() == null) {
            mSpeciesListAdapter = new UserSpeciesAdapter(UserProfile.this, mSpecies);
            mSpeciesList.setAdapter(mSpeciesListAdapter);
            mSpeciesList.setVisibility(View.VISIBLE);
        }
    }
    if (mIdentifications == null) {
        ((TextView) tabWidget.getChildAt(2).findViewById(R.id.count)).setVisibility(View.GONE);
        ((ProgressBar) tabWidget.getChildAt(2).findViewById(R.id.loading)).setVisibility(View.VISIBLE);
        mLoadingIdentificationsList.setVisibility(View.VISIBLE);
        mIdentificationsListEmpty.setVisibility(View.GONE);
        mIdentificationsList.setVisibility(View.GONE);
    } else {
        ((TextView) tabWidget.getChildAt(2).findViewById(R.id.count)).setVisibility(View.VISIBLE);
        ((ProgressBar) tabWidget.getChildAt(2).findViewById(R.id.loading)).setVisibility(View.GONE);
        ((TextView) tabWidget.getChildAt(2).findViewById(R.id.count)).setText(formatter.format(mTotalIdentifications));
        mLoadingIdentificationsList.setVisibility(View.GONE);
        if (mIdentifications.size() == 0) {
            mIdentificationsListEmpty.setVisibility(View.VISIBLE);
        } else {
            mIdentificationsListEmpty.setVisibility(View.GONE);
        }
        if (mIdentificationsList.getAdapter() == null) {
            mIdentificationsListAdapter = new UserIdentificationsAdapter(UserProfile.this, mIdentifications, mUser.getString("login"));
            mIdentificationsList.setAdapter(mIdentificationsListAdapter);
            mIdentificationsList.setVisibility(View.VISIBLE);
            // Make sure the images get loaded only when the user stops scrolling
            mIdentificationsList.setOnScrollListener(mIdentificationsListAdapter);
            mIdentificationsList.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                    JSONObject item = (JSONObject) view.getTag();
                    Intent intent = new Intent(UserProfile.this, ObservationViewerActivity.class);
                    intent.putExtra("observation", item.optJSONObject("observation").toString());
                    intent.putExtra("read_only", true);
                    intent.putExtra("reload", true);
                    startActivity(intent);
                }
            });
        }
    }
}
Also used : DecimalFormat(java.text.DecimalFormat) Intent(android.content.Intent) TabWidget(android.widget.TabWidget) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) JSONObject(org.json.JSONObject) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) ProgressBar(android.widget.ProgressBar)

Example 35 with TabWidget

use of android.widget.TabWidget in project android-viewbadger by jgilfelt.

the class DemoActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final TabHost tabHost = getTabHost();
    tabHost.addTab(tabHost.newTabSpec("demos").setIndicator("Badge Demos").setContent(R.id.tab1));
    tabHost.addTab(tabHost.newTabSpec("adapter").setIndicator("List Adapter").setContent(R.id.tab2));
    tabHost.addTab(tabHost.newTabSpec("tests").setIndicator("Layout Tests").setContent(R.id.tab3));
    // *** default badge ***
    View target = findViewById(R.id.default_target);
    BadgeView badge = new BadgeView(this, target);
    badge.setText("1");
    badge.show();
    // *** set position ***
    btnPosition = (Button) findViewById(R.id.position_target);
    badge1 = new BadgeView(this, btnPosition);
    badge1.setText("12");
    badge1.setBadgePosition(BadgeView.POSITION_CENTER);
    btnPosition.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge1.toggle();
        }
    });
    // *** badge/text size & colour ***
    btnColour = (Button) findViewById(R.id.colour_target);
    badge2 = new BadgeView(this, btnColour);
    badge2.setText("New!");
    badge2.setTextColor(Color.BLUE);
    badge2.setBadgeBackgroundColor(Color.YELLOW);
    badge2.setTextSize(12);
    btnColour.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge2.toggle();
        }
    });
    // *** default animation ***
    btnAnim1 = (Button) findViewById(R.id.anim1_target);
    badge3 = new BadgeView(this, btnAnim1);
    badge3.setText("84");
    btnAnim1.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge3.toggle(true);
        }
    });
    // *** custom animation ***
    btnAnim2 = (Button) findViewById(R.id.anim2_target);
    badge4 = new BadgeView(this, btnAnim2);
    badge4.setText("123");
    badge4.setBadgePosition(BadgeView.POSITION_TOP_LEFT);
    badge4.setBadgeMargin(15, 10);
    badge4.setBadgeBackgroundColor(Color.parseColor("#A4C639"));
    btnAnim2.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            TranslateAnimation anim = new TranslateAnimation(-100, 0, 0, 0);
            anim.setInterpolator(new BounceInterpolator());
            anim.setDuration(1000);
            badge4.toggle(anim, null);
        }
    });
    // *** custom background ***
    btnCustom = (Button) findViewById(R.id.custom_target);
    badge5 = new BadgeView(this, btnCustom);
    badge5.setText("37");
    badge5.setBackgroundResource(R.drawable.badge_ifaux);
    badge5.setTextSize(16);
    btnCustom.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge5.toggle(true);
        }
    });
    // *** clickable badge ***
    btnClick = (Button) findViewById(R.id.click_target);
    badge6 = new BadgeView(this, btnClick);
    badge6.setText("click me");
    badge6.setBadgeBackgroundColor(Color.BLUE);
    badge6.setTextSize(16);
    badge6.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(DemoActivity.this, "clicked badge", Toast.LENGTH_SHORT).show();
        }
    });
    btnClick.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge6.toggle();
        }
    });
    // *** tab ***
    TabWidget tabs = (TabWidget) findViewById(android.R.id.tabs);
    btnTab = (Button) findViewById(R.id.tab_btn);
    badge7 = new BadgeView(this, tabs, 0);
    badge7.setText("5");
    btnTab.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge7.toggle();
        }
    });
    // *** increment ***
    btnIncrement = (Button) findViewById(R.id.increment_target);
    badge8 = new BadgeView(this, btnIncrement);
    badge8.setText("0");
    btnIncrement.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (badge8.isShown()) {
                badge8.increment(1);
            } else {
                badge8.show();
            }
        }
    });
    // *** list adapter ****
    listDemo = (ListView) findViewById(R.id.tab2);
    listDemo.setAdapter(new BadgeAdapter(this));
}
Also used : TabHost(android.widget.TabHost) BounceInterpolator(android.view.animation.BounceInterpolator) BadgeView(com.readystatesoftware.viewbadger.BadgeView) OnClickListener(android.view.View.OnClickListener) TranslateAnimation(android.view.animation.TranslateAnimation) TabWidget(android.widget.TabWidget) TextView(android.widget.TextView) BadgeView(com.readystatesoftware.viewbadger.BadgeView) View(android.view.View) ListView(android.widget.ListView)

Aggregations

TabWidget (android.widget.TabWidget)37 View (android.view.View)21 FrameLayout (android.widget.FrameLayout)16 TabHost (android.widget.TabHost)15 LinearLayout (android.widget.LinearLayout)14 ViewGroup (android.view.ViewGroup)13 ListView (android.widget.ListView)12 TextView (android.widget.TextView)12 AdapterView (android.widget.AdapterView)9 AbsListView (android.widget.AbsListView)7 ExpandableListView (android.widget.ExpandableListView)6 ImageView (android.widget.ImageView)6 TabSpec (android.widget.TabHost.TabSpec)6 ResourceType (com.android.resources.ResourceType)6 ActionMenuView (android.widget.ActionMenuView)5 ActionMenuItemView (com.android.internal.view.menu.ActionMenuItemView)5 IconMenuItemView (com.android.internal.view.menu.IconMenuItemView)5 ListMenuItemView (com.android.internal.view.menu.ListMenuItemView)5 MenuView (com.android.internal.view.menu.MenuView)5 SuppressLint (android.annotation.SuppressLint)3