Example usage for android.app ActionBar setSubtitle

List of usage examples for android.app ActionBar setSubtitle

Introduction

In this page you can find the example usage for android.app ActionBar setSubtitle.

Prototype

public abstract void setSubtitle(@StringRes int resId);

Source Link

Document

Set the action bar's subtitle.

Usage

From source file:com.codebutler.farebot.activity.AdvancedCardInfoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_advanced_card_info);

    findViewById(R.id.error_button).setOnClickListener(new View.OnClickListener() {
        @Override//from w  w  w.  j av  a 2 s  .c om
        public void onClick(View v) {
            reportError();
        }
    });

    Serializer serializer = FareBotApplication.getInstance().getSerializer();
    mCard = Card.fromXml(serializer, getIntent().getStringExtra(AdvancedCardInfoActivity.EXTRA_CARD));

    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabPagerAdapter(this, viewPager);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(mCard.getCardType().toString() + " " + Utils.getHexString(mCard.getTagId(), "<error>"));

    if (mCard.getScannedAt().getTime() > 0) {
        String date = Utils.dateFormat(mCard.getScannedAt());
        String time = Utils.timeFormat(mCard.getScannedAt());
        actionBar.setSubtitle(Utils.localizeString(R.string.scanned_at_format, time, date));
    }

    if (getIntent().hasExtra(EXTRA_ERROR)) {
        mError = (Exception) getIntent().getSerializableExtra(EXTRA_ERROR);
        if (mError instanceof UnsupportedCardException) {
            findViewById(R.id.unknown_card).setVisibility(View.VISIBLE);
        } else if (mError instanceof UnauthorizedException) {
            findViewById(R.id.unauthorized_card).setVisibility(View.VISIBLE);
            findViewById(R.id.load_keys).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    startActivity(new Intent(AdvancedCardInfoActivity.this, AddKeyActivity.class));
                }
            });
        } else {
            findViewById(R.id.error).setVisibility(View.VISIBLE);
            ((TextView) findViewById(R.id.error_text)).setText(Utils.getErrorMessage(mError));
        }
    }

    CardHasManufacturingInfo infoAnnotation = mCard.getClass().getAnnotation(CardHasManufacturingInfo.class);
    if (infoAnnotation == null || infoAnnotation.value()) {
        mTabsAdapter.addTab(actionBar.newTab().setText(R.string.hw_detail), CardHWDetailFragment.class,
                getIntent().getExtras());
    }

    CardRawDataFragmentClass annotation = mCard.getClass().getAnnotation(CardRawDataFragmentClass.class);
    if (annotation != null) {
        Class rawDataFragmentClass = annotation.value();
        if (rawDataFragmentClass != null) {
            mTabsAdapter.addTab(actionBar.newTab().setText(R.string.data), rawDataFragmentClass,
                    getIntent().getExtras());
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        }
    }
}

From source file:tw.example.robert.myapplication.bluetoothchat.BluetoothChatFragment.java

/**
 * Updates the status on the action bar.
 *
 * @param resId a string resource ID/*from   w  w  w.  j a  v  a2s .  c om*/
 */
private void setStatus(int resId) {
    FragmentActivity activity = (FragmentActivity) getActivity();
    if (null == activity) {
        return;
    }
    final ActionBar actionBar = activity.getActionBar();
    if (null == actionBar) {
        return;
    }
    actionBar.setSubtitle(resId);
}

From source file:tw.example.robert.myapplication.bluetoothchat.BluetoothChatFragment.java

/**
 * Updates the status on the action bar.
 *
 * @param subTitle status/* w ww.  j a  v  a  2s . com*/
 */
private void setStatus(CharSequence subTitle) {
    FragmentActivity activity = (FragmentActivity) getActivity();
    if (null == activity) {
        return;
    }
    final ActionBar actionBar = activity.getActionBar();
    if (null == actionBar) {
        return;
    }
    actionBar.setSubtitle(subTitle);
}

From source file:app.hacked.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    //getActionBar().setIcon(R.drawable.ic_ab_logo);

    actionBar.setSubtitle("This app is UNOFFICIAL");

    queue = Volley.newRequestQueue(this);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override/*from w w  w.j a  va2  s.c  om*/
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    //GCM stuff
    GCMRegistrar.checkDevice(this);
    GCMRegistrar.checkManifest(this);
    regId = GCMRegistrar.getRegistrationId(this);

    if (regId.equals("")) {
        Log.v("GCM", "Registering");
        GCMRegistrar.register(this, API.SENDER_ID);
    } else {
        Log.v("GCM", "Already registered");
    }

    //Log.e("GCMID",GCMRegistrar.getRegistrationId(this));

    JSONObject post = new JSONObject();
    try {
        post.put("gcmid", regId);
        post.put("deviceid", Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID));
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(this, "An Error Was encountered connecting to the GCM cloud. Chat will be unavailable",
                Toast.LENGTH_LONG).show();
        return;
    }

    JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.POST,
            "http://hackedioapp.networksaremadeofstring.co.uk/registergcm.php", post,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    Log.e("response", response.toString());
                    try {
                        if (response.has("success") && response.getBoolean("success")) {
                            //Alls cool
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    // TODO Auto-generated method stub
                }
            });

    queue.add(jsObjRequest);
}

From source file:com.deange.textfaker.ui.activity.MessageActivity.java

private void setupActionBar() {
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);

        if (mConversation != null) {
            actionBar.setTitle(mConversation.getName());
            actionBar.setSubtitle(mConversation.getNumber());
        }/*  w ww . ja  v a  2s  .  c  o m*/
    }
}

From source file:com.fpil.android.remotesensor.MainDisplay.java

/**
 * Updates the status on the action bar.
 *
 * @param resId a string resource ID/*  www . j  a v a  2  s. c  o m*/
 */
public void setStatus(int resId) {
    FragmentActivity activity = getActivity();
    if (null == activity) {
        return;
    }
    final ActionBar actionBar = activity.getActionBar();
    if (null == actionBar) {
        return;
    }
    actionBar.setSubtitle(resId);
}

From source file:com.shrlnm.android.erm.ElmRenaultMonitor_Main.java

private void setStatus(int resId) {
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setSubtitle(resId);
    }//w  w w .j av  a 2 s. c om
}

From source file:com.shrlnm.android.erm.ElmRenaultMonitor_Main.java

private void setStatus(CharSequence subTitle) {
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setSubtitle(subTitle);
    }/*from   w  w  w  .  j av  a2 s  . c  o  m*/
}

From source file:com.richtodd.android.quiltdesign.app.BlockEditActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_block_edit);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    m_blockNameArgument = getIntent().getStringExtra(ARG_BLOCK_NAME);

    if (savedInstanceState != null) {
        m_saveAsBlockName = savedInstanceState.getString("saveAsBlockName");
        m_theme = (Theme) savedInstanceState.getParcelable("theme");
    }//w  w w.j a v a  2s . co m

    ActionBar ab = getActionBar();
    ab.setTitle("Edit Block");
    ab.setSubtitle(getCurrentBlockName());

    FragmentManager fm = getFragmentManager();

    // Create color settings fragment.
    {
        Fragment f = fm.findFragmentById(R.id.layout_blockEditFragment);
        if (f == null) {
            f = BlockEditFragment.create(m_blockNameArgument);
            fm.beginTransaction().add(R.id.layout_blockEditFragment, f).commit();
        }
    }

    m_themeView = (ThemeView) findViewById(R.id.themeView);
    m_themeView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Swatch swatch = (Swatch) m_themeView.getItemAtPosition(position);
            BlockEditFragment fragment = getBlockEditFragment();
            if (fragment != null) {
                fragment.setColor(swatch.getColor());
            }

        }
    });
    m_themeView.setTheme(m_theme);

    m_button_setColor = (Button) findViewById(R.id.button_setColor);
    m_button_setColor.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            chooseColor();
        }
    });

    m_button_addPiece = (Button) findViewById(R.id.button_addPiece);
    m_button_addPiece.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            BlockEditFragment fragment = getBlockEditFragment();
            int color = fragment.getColor();
            PaperPiecedBlockPiece piece = fragment.addPiece(color);
            onPieceSelected(fragment, piece);
        }
    });

    m_button_deletePiece = (Button) findViewById(R.id.button_deletePiece);
    m_button_deletePiece.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            BlockEditFragment fragment = getBlockEditFragment();
            fragment.deletePiece();
            onPieceSelected(fragment, null);
        }
    });

    ImageView button_refreshTheme = (ImageView) findViewById(R.id.button_refreshTheme);
    button_refreshTheme.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            refreshTheme();
        }
    });

    ImageView button_selectTheme = (ImageView) findViewById(R.id.button_selectTheme);
    button_selectTheme.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            chooseTheme();
        }
    });
}

From source file:com.semaphore.sm.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    boolean darktheme = prefs.getBoolean("darktheme", false);
    if (darktheme)
        setTheme(android.R.style.Theme_Holo);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);// w ww  . j  av a2s  .c  om
    // setup action bar for tabs

    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
        // Ignore
    }

    if ("mako".equals(android.os.Build.DEVICE))
        Device = SemaDevices.Mako;
    else
        Device = SemaDevices.I9000;

    if (Device == SemaDevices.Mako)
        sp = new SemaN4Properties();
    else
        sp = new SemaI9000Properties();

    checkSU_BB();
    unpackScripts();

    checkFirstRun();

    mPagerAdapter = new PagerAdapter(getSupportFragmentManager(), this);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mPagerAdapter);

    PagerTabStrip pagerTitleStrip = (PagerTabStrip) findViewById(R.id.pager_title_strip);
    pagerTitleStrip.setDrawFullUnderline(true);
    pagerTitleStrip.setTabIndicatorColor(0x33b5e5);

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);

    actionBar.setTitle("Semaphore Manager");

    actionBar.setSubtitle(SemaphoreVer);

    updateSummaries();

}