2011-08-27 33 views
10

Tôi đang tìm cách triển khai ActionBar trong Android 2.1 đến 2.3.4 nơi tôi có thể tự động đặt nội dung của thanh tác vụ từ hoạt động cụ thể và cũng có thể thực hiện các thao tác khi nhấp vào các nút từ thanh tác vụ .Android Action Bar

Có bất kỳ lib nguồn mở nào thuộc loại này hay ai đó có thể giúp tôi cách bắt đầu xây dựng như cũ.

+1

[Ở đây liên kết là sử dụng đầy đủ.] [1] [1]: http://stackoverflow.com/questions/6794129/quickaction-bar-on-android-google-map -marker/7175968 # 7175968 –

Trả lời

6

Hãy xem http://android.cyrilmottier.com/?p=240 - Greendroid.

Nếu nó không phù hợp với nhu cầu của bạn, tôi khuyên bạn nên tạo "tiện ích con" của riêng mình, chỉ cần một số bố cục và thổi phồng ActionBar theo chương trình.

3

Câu hỏi này đã có câu trả lời được chấp nhận. Nhưng tôi đã có một số vấn đề với việc thực hiện SherlockActionBar và tìm kiếm nhiều hơn và tìm thấy điều này. Chúng tôi có thể sử dụng ActionBar bên dưới Cấp API 11 theo hướng dẫn chính thức này được cung cấp tại Android chính thức.

Đọc hướng dẫn này từ trang web chính thức của Android. Action Bar Android Bạn chỉ cần bao gồm android-support-v7-appcompat.jar bình hỗ trợ trong dự án của mình từ đường dẫn android-sdk-windows\extras\android\support\v7\appcompat\libs trên đĩa của bạn. Sau đó, bạn có thể sử dụng ActionBar bên dưới API 11 trong Android.

Hướng dẫn Android chính thức ở đây:Action Bar Android Official Thanh khóa tạo sự cố cho tôi sau đó tôi nhận được giải pháp này.

+0

một câu hỏi cũ của nó: D –

+0

Vâng, tôi biết. Nhưng khách truy cập sẽ có thể chọn từ nhiều tùy chọn để triển khai trong ứng dụng của họ. – Master

+0

@Hoosier Vui lòng không đăng câu trả lời trùng lặp. Nếu các câu hỏi có cùng cờ với bản sao. Nếu không điều chỉnh câu trả lời của bạn cho câu hỏi thay vì đăng nhiều bản sao của cùng một câu hỏi. – ChrisF

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); 

     } 

    } 



} 
+1

cố gắng thêm một số mô tả –