Android 操作栏

发布于 2024-12-01 16:53:54 字数 122 浏览 2 评论 0原文

我正在寻找 Android 2.1 到 2.3.4 中 ActionBar 的实现,其中我可以动态设置特定活动中操作栏的内容以及单击操作栏中按钮时的操作。

是否有此类开源库,或者有人可以帮助我如何开始构建相同的库。

I am looking for an implementation of the ActionBar in Android 2.1 to 2.3.4 where i can dynamically set the contents of the action bar from the particular activity and also the actions on click of the buttons from the action bar.

Is there any open source lib of this sort or can someone help me how to start on building the same.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

清眉祭 2024-12-08 16:53:54

看看 http://android.cyrilmottier.com/?p=240 - Greendroid 。

如果它不符合您的需求,我建议创建您自己的“小部件”,只需要一些布局并以编程方式膨胀 ActionBar。

Have a look at http://android.cyrilmottier.com/?p=240 - Greendroid.

If it doesn't fit your needs, I suggest creating your own "widget", just need some layouts and inflate the ActionBar programmatically.

深爱成瘾 2024-12-08 16:53:54

这个问题已经有一个公认的答案。但我在 SherlockActionBar 实现方面遇到了一些问题,并进行了更多搜索并发现了这个。我们可以按照 Android 官方给出的官方教程,在 API level 11 以下使用 ActionBar

从 Android 官方网站阅读本教程。
Android 操作栏
您只需将 android-sdk-windows\extras\android\support\v7\appcompat\libsandroid-support-v7-appcompat.jar 支持 jar 包含在您的项目中即可code> 磁盘上的路径。然后就可以在Android中使用API​​ 11以下的ActionBar了。

官方 Android 教程在这里: Action Bar Android 官方< /a> Sherlock 酒吧给我带来了问题,然后我得到了这个解决方案。

This question already has an accepted answer. But I was having some problems with SherlockActionBar implementation and searched more and found this. We can use ActionBar below API level 11 following this official tutorial given at official Android.

Read this tutorial from Android's official site.
Action Bar Android
You just need to include android-support-v7-appcompat.jar support jar in your project from your android-sdk-windows\extras\android\support\v7\appcompat\libs path on your disk. Then you can use ActionBar below API 11 in Android.

Official Android Tutorial is here: Action Bar Android Official Sherlock bar was creating issues for me then I got this solution.

你是我的挚爱i 2024-12-08 16:53:54
package com.util;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBar.LayoutParams;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.android.volley.RequestQueue;


public class BaseActivity extends ActionBarActivity {
    public View mCustomView;
    public static SessionManager session;
    public ProgressDialog pDialog;
    public ConnectionDetector checkConnection;
    RequestQueue queue;
    AlertDialog alertDialog;
    private boolean isActionBarEnable;
    public Typeface font_bold, font_regular, font_light, font_thin;
    public ImageView ivBack,ivHome,iv_history;
    public TextView tvTitle;
    public ProgressBar progressForWebView;

    public BaseActivity() {

    }

    public BaseActivity(boolean isActionBarEnable) {
        this.isActionBarEnable = isActionBarEnable;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);


        if (isActionBarEnable) {

            ActionBar actionBar = getSupportActionBar();
            actionBar.setDisplayHomeAsUpEnabled(false);
            actionBar.setDisplayShowHomeEnabled(false);
            actionBar.setDisplayUseLogoEnabled(false);
            actionBar.setDisplayShowTitleEnabled(false);

            LayoutInflater mInflater = LayoutInflater.from(this);

            mCustomView = mInflater.inflate(R.layout.custom_actionbar, null);

            ivBack = (ImageView) mCustomView.findViewById(R.id.custom_actionbar_iv_back);
            iv_history = (ImageView) mCustomView.findViewById(R.id.custom_actionbar_iv_history);
            ivHome = (ImageView) mCustomView.findViewById(R.id.custom_actionbar_iv_home);

            tvTitle = (TextView) mCustomView.findViewById(R.id.custom_actionbar_title);

            progressForWebView = (ProgressBar) mCustomView.findViewById(R.id.custom_actionbar_progressbar);


            actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_CUSTOM);
            actionBar.setDisplayShowCustomEnabled(true);

            actionBar.setCustomView(mCustomView, new ActionBar.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
            Toolbar parent = (Toolbar) mCustomView.getParent();
            parent.setContentInsetsAbsolute(0, 0);

        }

    }



}
package com.util;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBar.LayoutParams;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.android.volley.RequestQueue;


public class BaseActivity extends ActionBarActivity {
    public View mCustomView;
    public static SessionManager session;
    public ProgressDialog pDialog;
    public ConnectionDetector checkConnection;
    RequestQueue queue;
    AlertDialog alertDialog;
    private boolean isActionBarEnable;
    public Typeface font_bold, font_regular, font_light, font_thin;
    public ImageView ivBack,ivHome,iv_history;
    public TextView tvTitle;
    public ProgressBar progressForWebView;

    public BaseActivity() {

    }

    public BaseActivity(boolean isActionBarEnable) {
        this.isActionBarEnable = isActionBarEnable;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);


        if (isActionBarEnable) {

            ActionBar actionBar = getSupportActionBar();
            actionBar.setDisplayHomeAsUpEnabled(false);
            actionBar.setDisplayShowHomeEnabled(false);
            actionBar.setDisplayUseLogoEnabled(false);
            actionBar.setDisplayShowTitleEnabled(false);

            LayoutInflater mInflater = LayoutInflater.from(this);

            mCustomView = mInflater.inflate(R.layout.custom_actionbar, null);

            ivBack = (ImageView) mCustomView.findViewById(R.id.custom_actionbar_iv_back);
            iv_history = (ImageView) mCustomView.findViewById(R.id.custom_actionbar_iv_history);
            ivHome = (ImageView) mCustomView.findViewById(R.id.custom_actionbar_iv_home);

            tvTitle = (TextView) mCustomView.findViewById(R.id.custom_actionbar_title);

            progressForWebView = (ProgressBar) mCustomView.findViewById(R.id.custom_actionbar_progressbar);


            actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_CUSTOM);
            actionBar.setDisplayShowCustomEnabled(true);

            actionBar.setCustomView(mCustomView, new ActionBar.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
            Toolbar parent = (Toolbar) mCustomView.getParent();
            parent.setContentInsetsAbsolute(0, 0);

        }

    }



}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文