本文整理汇总了Java中android.app.ActionBar.setCustomView方法的典型用法代码示例。如果您正苦于以下问题:Java ActionBar.setCustomView方法的具体用法?Java ActionBar.setCustomView怎么用?Java ActionBar.setCustomView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.ActionBar
的用法示例。
在下文中一共展示了ActionBar.setCustomView方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.app.ActionBar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.action_bar_display_options);
findViewById(R.id.toggle_home_as_up).setOnClickListener(this);
findViewById(R.id.toggle_show_home).setOnClickListener(this);
findViewById(R.id.toggle_use_logo).setOnClickListener(this);
findViewById(R.id.toggle_show_title).setOnClickListener(this);
findViewById(R.id.toggle_show_custom).setOnClickListener(this);
findViewById(R.id.toggle_navigation).setOnClickListener(this);
findViewById(R.id.cycle_custom_gravity).setOnClickListener(this);
mCustomView = getLayoutInflater().inflate(R.layout.action_bar_display_options_custom, null);
// Configure several action bar elements that will be toggled by display options.
final ActionBar bar = getActionBar();
bar.setCustomView(mCustomView,
new ActionBar.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
bar.addTab(bar.newTab().setText("Tab 1").setTabListener(this));
bar.addTab(bar.newTab().setText("Tab 2").setTabListener(this));
bar.addTab(bar.newTab().setText("Tab 3").setTabListener(this));
}
示例2: setupActionBar
import android.app.ActionBar; //导入方法依赖的package包/类
private void setupActionBar() {
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setCustomView(R.layout.action_bar);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.getCustomView().findViewById(R.id.action_bar_back_icon).setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
}
}
示例3: initActionBar
import android.app.ActionBar; //导入方法依赖的package包/类
protected void initActionBar(){
if (DEBUG) Timber.d("initActionBar");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ActionBar ab = readyActionBarToCustomView();
/*http://stackoverflow.com/questions/16026818/actionbar-custom-view-with-centered-imageview-action-items-on-sides*/
actionBarView = inflateActionBarView(R.layout.chat_sdk_actionbar_chat_activity);
boolean changed;
TextView txtName = (TextView) actionBarView.findViewById(R.id.chat_sdk_name);
changed = setThreadName(txtName);
final CircleImageView circleImageView = (CircleImageView) actionBarView.findViewById(R.id.chat_sdk_circle_image);
final ImageView imageView = (ImageView) actionBarView.findViewById(R.id.chat_sdk_round_corner_image);
final View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
};
changed = setThreadImage(circleImageView, imageView, onClickListener) || changed;
if (changed)
ab.setCustomView(actionBarView);
}
}
示例4: setupActionBarDoneCancel
import android.app.ActionBar; //导入方法依赖的package包/类
public static void setupActionBarDoneCancel(int layoutId,
Activity activity,
int doneId,
View.OnClickListener onDoneListener,
int cancelId,
View.OnClickListener onCancelListener) {
ActionBar actionBar = activity.getActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(makeDoneCancelLayout(layoutId, activity,
doneId, onDoneListener,
cancelId, onCancelListener));
}
示例5: onCreate
import android.app.ActionBar; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.address_book_listview);
final ActionBar chatting = getActionBar();
chatting.setCustomView(R.layout.custom_address_book);
chatting.setDisplayShowTitleEnabled(false);
chatting.setDisplayShowCustomEnabled(true);
chatting.setDisplayShowHomeEnabled(false);
backBtn = (Button) findViewById(R.id.backBtn);
AQuery aq = new AQuery(getApplicationContext());
aq.ajax("http://52.79.134.200/friend", String.class, new AjaxCallback<String>() {
@Override
public void callback(String url, String response, AjaxStatus status) {
if(status.getCode() == 200) {
try {
JSONObject res = new JSONObject(response);
} catch(JSONException e) {
e.printStackTrace();
}
} else {
}
}
}.method(AQuery.METHOD_GET).cookie("UserSession", SessionManager.getCookieFromDB(getApplicationContext())));
backBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getApplicationContext(), Main.class));
}
});
}
示例6: onClick
import android.app.ActionBar; //导入方法依赖的package包/类
public void onClick(View v) {
final ActionBar bar = getActionBar();
int flags = 0;
switch (v.getId()) {
case R.id.toggle_home_as_up:
flags = ActionBar.DISPLAY_HOME_AS_UP;
break;
case R.id.toggle_show_home:
flags = ActionBar.DISPLAY_SHOW_HOME;
break;
case R.id.toggle_use_logo:
flags = ActionBar.DISPLAY_USE_LOGO;
break;
case R.id.toggle_show_title:
flags = ActionBar.DISPLAY_SHOW_TITLE;
break;
case R.id.toggle_show_custom:
flags = ActionBar.DISPLAY_SHOW_CUSTOM;
break;
case R.id.toggle_navigation:
bar.setNavigationMode(
bar.getNavigationMode() == ActionBar.NAVIGATION_MODE_STANDARD
? ActionBar.NAVIGATION_MODE_TABS
: ActionBar.NAVIGATION_MODE_STANDARD);
return;
case R.id.cycle_custom_gravity:
ActionBar.LayoutParams lp = (ActionBar.LayoutParams) mCustomView.getLayoutParams();
int newGravity = 0;
switch (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
case Gravity.LEFT:
newGravity = Gravity.CENTER_HORIZONTAL;
break;
case Gravity.CENTER_HORIZONTAL:
newGravity = Gravity.RIGHT;
break;
case Gravity.RIGHT:
newGravity = Gravity.LEFT;
break;
}
lp.gravity = lp.gravity & ~Gravity.HORIZONTAL_GRAVITY_MASK | newGravity;
bar.setCustomView(mCustomView, lp);
return;
}
int change = bar.getDisplayOptions() ^ flags;
bar.setDisplayOptions(change, flags);
}
示例7: init
import android.app.ActionBar; //导入方法依赖的package包/类
protected void init() {
setContentView(R.layout.wallpaper_cropper);
mCropView = (CropView) findViewById(R.id.cropView);
mProgressView = findViewById(R.id.loading);
Intent cropIntent = getIntent();
final Uri imageUri = cropIntent.getData();
if (imageUri == null) {
Log.e(LOGTAG, "No URI passed in intent, exiting WallpaperCropActivity");
finish();
return;
}
// Action bar
// Show the custom action bar view
final ActionBar actionBar = getActionBar();
actionBar.setCustomView(R.layout.actionbar_set_wallpaper);
actionBar.getCustomView().setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
actionBar.hide();
// Never fade on finish because we return to the app that started us (e.g.
// Photos), not the home screen.
cropImageAndSetWallpaper(imageUri, null, false /* shouldFadeOutOnFinish */);
}
});
mSetWallpaperButton = findViewById(R.id.set_wallpaper_button);
// Load image in background
final BitmapRegionTileSource.InputStreamSource bitmapSource =
new BitmapRegionTileSource.InputStreamSource(this, imageUri);
mSetWallpaperButton.setEnabled(false);
Runnable onLoad = new Runnable() {
public void run() {
if (bitmapSource.getLoadingState() != BitmapSource.State.LOADED) {
Toast.makeText(WallpaperCropActivity.this, R.string.wallpaper_load_fail,
Toast.LENGTH_LONG).show();
finish();
} else {
mSetWallpaperButton.setEnabled(true);
}
}
};
setCropViewTileSource(bitmapSource, true, false, null, onLoad);
}