Example usage for android.app ActionBar setTitle

List of usage examples for android.app ActionBar setTitle

Introduction

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

Prototype

public abstract void setTitle(@StringRes int resId);

Source Link

Document

Set the action bar's title.

Usage

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");
    }//from  w w  w.j a va 2  s  .c om

    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.example.lowviscam.GalleryActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    isLight = getIntent().getExtras().getBoolean("isLight");
    if (isLight == false) {
        this.setTheme(R.style.AppBaseThemeDark);
    } else {//www .  j  a v a2  s . c om
        this.setTheme(R.style.AppBaseTheme);
    }
    setContentView(R.layout.activity_gallery);

    // Retrieve APHont font and apply it
    mFace = Typeface.createFromAsset(getAssets(), "fonts/APHont-Regular_q15c.otf");
    SpannableString s = new SpannableString("Image Gallery");
    s.setSpan(new TypefaceSpan(this, "APHont-Bold_q15c.otf"), 0, s.length(),
            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    // Update the action bar title with the TypefaceSpan instance
    ActionBar actionBar = getActionBar();
    actionBar.setTitle(s);

    actionBar.setDisplayHomeAsUpEnabled(true);

    // Fetch the {@link LayoutInflater} service so that new views can be created
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    // Find the {@link GridView} that was already defined in the XML layout
    GridView gridView = (GridView) findViewById(R.id.grid);

    // Initialize the adapter with all the coupons. Set the adapter on the {@link GridView}.
    try {
        gridView.setAdapter(new CouponAdapter(inflater, createAllCoupons()));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    // Set a click listener for each picture in the grid
    gridView.setOnItemClickListener(this);
    gridView.setOnTouchListener(new OnSwipeTouchListener() {

        public void onSwipeTop() {
            //Toast.makeText(GalleryActivity.this, "top", Toast.LENGTH_SHORT).show();
        }

        public void onSwipeRight() {
            //Toast.makeText(GalleryActivity.this, "right", Toast.LENGTH_SHORT).show();
        }

        public void onSwipeLeft() {
            //Toast.makeText(GalleryActivity.this, "left", Toast.LENGTH_SHORT).show();
        }

        public void onSwipeBottom() {
            //Toast.makeText(GalleryActivity.this, "bottom", Toast.LENGTH_SHORT).show();
        }

    });
    gridView.setOnItemLongClickListener(new OnItemLongClickListener() {

        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            // Find coupon that was clicked based off of position in adapter
            Coupon coupon = (Coupon) parent.getItemAtPosition(position);
            //Get absolutepath of image for adding.
            File list[] = mediaStorageDir.listFiles();
            File tmpFile = list[list.length - position - 1];
            String photoUri = coupon.mImageUri.toString();
            try {
                photoUri = MediaStore.Images.Media.insertImage(getContentResolver(), tmpFile.getAbsolutePath(),
                        null, null);
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            // Create share intent
            Intent shareIntent = ShareCompat.IntentBuilder.from(GalleryActivity.this).setText(coupon.mTitle)
                    .setType("image/jpeg").setStream(Uri.parse(photoUri))
                    .setChooserTitle(getString(R.string.share_using)).createChooserIntent();
            startActivity(shareIntent);

            return true;
        }
    });

}

From source file:com.decad3nce.aegis.AegisActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);/* www.  j av a 2 s  .  com*/
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setDisplayShowHomeEnabled(true);
    bar.setHomeButtonEnabled(true);
    bar.setTitle(R.string.app_name);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.alarm_section), SMSAlarmFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.lock_section), SMSLockFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.wipe_section), SMSWipeFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.locate_section), SMSLocateFragment.class, null);
    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }

    final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);

    alarmEnabled = preferences.getBoolean(PREFERENCES_ALARM_ENABLED,
            this.getResources().getBoolean(R.bool.config_default_alarm_enabled));
    wipeEnabled = preferences.getBoolean(PREFERENCES_WIPE_ENABLED,
            this.getResources().getBoolean(R.bool.config_default_wipe_enabled));
    lockEnabled = preferences.getBoolean(PREFERENCES_LOCK_ENABLED,
            this.getResources().getBoolean(R.bool.config_default_lock_enabled));
    locateEnabled = preferences.getBoolean(PREFERENCES_LOCATE_ENABLED,
            this.getResources().getBoolean(R.bool.config_default_locate_enabled));

    invalidateOptionsMenu();

    mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
}

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 w w  .  j  av  a 2 s.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();

}

From source file:fr.cph.chicago.activity.BusActivity.java

@Override
public final boolean onCreateOptionsMenu(final Menu menu) {
    super.onCreateOptionsMenu(menu);
    this.mMenu = menu;

    // Inflate menu with no search
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main_no_search, menu);

    // Modify action bar title
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle("Bus");

    // Load top bar animation
    MenuItem refreshMenuItem = menu.findItem(R.id.action_refresh);
    refreshMenuItem.setActionView(R.layout.progressbar);
    refreshMenuItem.expandActionView();//  w  w  w.  j  a v  a 2 s . co m

    return true;
}

From source file:com.emman.tame.MainActivity.java

public void restoreActionBar() {
    ActionBar actionBar = getActionBar();

    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(R.layout.action_bar);

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(mTitle);
}

From source file:com.app.blockydemo.ui.fragment.FormulaEditorFragment.java

private void resetActionBar() {
    ActionBar actionBar = getActivity().getActionBar();
    actionBar.setTitle("");
}

From source file:com.ls.sip.CameraFragment.java

@Override
public void onHiddenChanged(boolean isHidden) {
    super.onHiddenChanged(isHidden);

    if (!isHidden) {
        ActionBar ab = getActivity().getActionBar();

        if (ab != null) {
            ab.setBackgroundDrawable(//from   www  . j  ava 2 s.co  m
                    ContextCompat.getDrawable(getActivity(), R.drawable.cwac_cam2_action_bar_bg_transparent));
            ab.setTitle("");

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                ab.setDisplayHomeAsUpEnabled(false);
            } else {
                ab.setDisplayShowHomeEnabled(false);
                ab.setHomeButtonEnabled(false);
            }
        }

        if (btnTakePicture != null) {
            btnTakePicture.setEnabled(true);
            btnSwitch.setEnabled(true);
        }
    }
}

From source file:com.concentricsky.android.khanacademy.app.TopicListActivity.java

@Override
protected void onStart() {
    super.onStart();

    stopped = false;//from www .j  a v  a  2s .  c o m

    mainMenuDelegate = new MainMenuDelegate(this);
    gridView = (GridView) findViewById(R.id.activity_topic_list_grid);
    gridView.setOnItemClickListener(clickListener);

    ActionBar ab = getActionBar();
    ab.setDisplayHomeAsUpEnabled(true);
    ab.setTitle("Topics");

    requestDataService(new ObjectCallback<KADataService>() {
        @Override
        public void call(final KADataService dataService) {
            TopicListActivity.this.dataService = dataService;

            try {
                thumbnailManager = dataService.getThumbnailManager();

                dao = dataService.getHelper().getTopicDao();
                if (topicId != null) {
                    topic = dao.queryForId(topicId);
                } else {
                    topic = dataService.getRootTopic();
                    topicId = topic.getId();
                }

                // DEBUG
                if (topic == null)
                    return;

                // header
                headerView = findViewById(R.id.header_topic_list);

                ((TextView) headerView.findViewById(R.id.header_video_list_title)).setText(topic.getTitle());

                String desc = topic.getDescription();
                TextView descView = (TextView) headerView.findViewById(R.id.header_video_list_description);
                if (desc != null && desc.length() > 0) {
                    descView.setText(Html.fromHtml(desc));
                    descView.setVisibility(View.VISIBLE);
                } else {
                    descView.setVisibility(View.GONE);
                }

                // Find child count for this parent topic.
                boolean videoChildren = Topic.CHILD_KIND_VIDEO.equals(topic.getChild_kind());
                String[] idArg = { topic.getId() };
                String sql = videoChildren ? "select count() from topicvideo where topic_id=?"
                        : "select count() from topic where parentTopic_id=?";
                int count = (int) dao.queryRawValue(sql, idArg);
                String countFormat = getString(
                        videoChildren ? R.string.format_video_count : R.string.format_topic_count);

                // Set header count string.
                ((TextView) headerView.findViewById(R.id.header_video_list_count))
                        .setText(String.format(countFormat, count));

                final ImageView thumb = (ImageView) headerView.findViewById(R.id.header_video_list_thumbnail);
                if (thumb != null) {
                    new AsyncTask<Void, Void, Bitmap>() {
                        @Override
                        public Bitmap doInBackground(Void... arg) {
                            Bitmap bmp = thumbnailManager.getThumbnail(
                                    TopicListActivity.this.topic.getThumb_id(), Thumbnail.QUALITY_SD);
                            return bmp;
                        }

                        @Override
                        public void onPostExecute(Bitmap bmp) {
                            thumb.setImageBitmap(bmp);
                        }
                    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                }

                // list
                if (topicCursor != null) {
                    topicCursor.close();
                }
                topicCursor = buildCursor(topicId);

                ListAdapter adapter = new TopicGridAdapter(topicCursor);
                gridView.setAdapter(adapter);

                // Request the topic and its children be updated from the api.
                List<Topic> children = dao.queryForEq("parentTopic_id", topic.getId());
                List<String> toUpdate = new ArrayList<String>();
                for (Topic child : children) {
                    toUpdate.add(child.getId());
                }
                toUpdate.add(topic.getId());
            } catch (SQLException e) {
                e.printStackTrace();
            }

        }
    });

    IntentFilter filter = new IntentFilter();
    filter.addAction(ACTION_LIBRARY_UPDATE);
    filter.addAction(ACTION_BADGE_EARNED);
    filter.addAction(ACTION_TOAST);
    LocalBroadcastManager.getInstance(this).registerReceiver(receiver, filter);
}

From source file:za.ac.uct.cs.lwsjam005.eshelf.activities.ReadActivity.java

private void setupActionBar() {
    ActionBar actionBar = getActionBar();

    actionBar.setDisplayHomeAsUpEnabled(true);

    actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#aa000022")));
    actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#aa000022")));
    actionBar.setSplitBackgroundDrawable(new ColorDrawable(Color.parseColor("#aa000022")));

    actionBar.setIcon(thisBook.getIcon());
    actionBar.setTitle(thisBook.getTitle());
    actionBar.setSubtitle(thisBook.getAuthor());

}