最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android巧用ActionBar實(shí)現(xiàn)下拉式導(dǎo)航

 更新時(shí)間:2016年05月25日 14:39:23   作者:summerpxy  
這篇文章主要為大家詳細(xì)介紹了Android巧用ActionBar實(shí)現(xiàn)下拉式導(dǎo)航的相關(guān)資料,具有一定的實(shí)用性和參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了ActionBar下拉式導(dǎo)航的實(shí)現(xiàn)代碼,供大家參考,具體內(nèi)容如下

利用Actionbar同樣可以很輕松的實(shí)現(xiàn)下拉式的導(dǎo)航方式,若想實(shí)現(xiàn)這種效果:

1)actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST) 

2)setListNavigationCallbacks(SpinnerAdapter adapter,ActionBar.OnNavigationListener callback).

首先是創(chuàng)建一個(gè)Fragment類:

package ccom.app.main;

import android.annotation.SuppressLint;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.TextView;

@SuppressLint("NewApi")
public class MyFragment extends Fragment {

 @Override
 public View onCreateView(LayoutInflater inflater, ViewGroup container,
   Bundle savedInstanceState) {

  Context context = this.getActivity();

  TextView tv = new TextView(context);

  Bundle arc = this.getArguments();

  int tabs=arc.getInt("key");
  
  tv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
    LayoutParams.WRAP_CONTENT));

  tv.setText("hello actionbar "+tabs);

  return tv;

 }

}

main.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 tools:context=".Main" >

 <LinearLayout
  android:id="@+id/content"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" />

</RelativeLayout>

自定義的用于顯示textview的mytextview.xml:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/text1"
 android:textColor="#fff"
 android:background="#696969"
 android:layout_width="60sp"
 android:layout_height="match_parent"
 android:textAppearance="?android:attr/textAppearanceListItemSmall"
 android:gravity="center_vertical"
 android:paddingStart="?android:attr/listPreferredItemPaddingStart"
 android:minHeight="?android:attr/listPreferredItemHeightSmall"
/>

Main.java

package ccom.app.main;

import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.widget.ArrayAdapter;

@SuppressLint("NewApi")
public class Main extends Activity implements ActionBar.OnNavigationListener {

 ActionBar actionBar = null;

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

  actionBar = this.getActionBar();

  actionBar.setDisplayShowTitleEnabled(true);

  actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

  actionBar.setListNavigationCallbacks(new ArrayAdapter(Main.this,
    R.layout.mytextview, R.id.text1, new String[] { "tab1", "tab2",
      "tab3" }), this);

 }

 @Override
 public boolean onNavigationItemSelected(int itemPosition, long itemId) {

  MyFragment mf = new MyFragment();
  Bundle bundle = new Bundle();
  bundle.putInt("key", itemPosition + 1);
  mf.setArguments(bundle);

  FragmentTransaction action = this.getFragmentManager()
    .beginTransaction();
  action.replace(R.id.content, mf);
  action.commit();
  return true;
 }

}

實(shí)現(xiàn)的效果如圖:

以上就是本文的全部?jī)?nèi)容,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android巧用ActionBar實(shí)現(xiàn)下拉式導(dǎo)航

    Android巧用ActionBar實(shí)現(xiàn)下拉式導(dǎo)航

    這篇文章主要為大家詳細(xì)介紹了Android巧用ActionBar實(shí)現(xiàn)下拉式導(dǎo)航的相關(guān)資料,具有一定的實(shí)用性和參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-05-05
  • iBeacon使用藍(lán)牙連接范圍精確到1-3米

    iBeacon使用藍(lán)牙連接范圍精確到1-3米

    這篇文章主要為大家詳細(xì)介紹了iBeacon使用藍(lán)牙連接范圍精確到1到3米,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-10-10
  • Android繪制機(jī)器人小實(shí)例

    Android繪制機(jī)器人小實(shí)例

    這篇文章主要為大家詳細(xì)介紹了Android繪制機(jī)器人小實(shí)例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-12-12
  • 使用Android Studio 開(kāi)發(fā)自己的SDK教程

    使用Android Studio 開(kāi)發(fā)自己的SDK教程

    很多時(shí)候我們要將自己開(kāi)發(fā)一個(gè)類庫(kù)打包成jar包以供他調(diào)用,這個(gè)jar包也叫你自己的SDK或者叫l(wèi)ibrary。android studio生成jar包的方法與eclipse有所不同。在studio中l(wèi)ibrary其實(shí)是module的概念。
    2017-10-10
  • Android自定義照相機(jī)詳解

    Android自定義照相機(jī)詳解

    幾乎每個(gè)APP都會(huì)用的相機(jī)功能,下面小編把內(nèi)容整理分享到腳本之家平臺(tái),供大家參考
    2016-04-04
  • Android_UI 仿QQ側(cè)滑菜單效果的實(shí)現(xiàn)

    Android_UI 仿QQ側(cè)滑菜單效果的實(shí)現(xiàn)

    相信大家對(duì)QQ側(cè)滑菜單的效果已經(jīng)不陌生了吧,側(cè)滑進(jìn)入個(gè)人頭像一側(cè),進(jìn)行對(duì)頭像的更改,我的收藏,QQ錢包,我的文件等一系列的操作,下面小編給大家分享Android_UI 仿QQ側(cè)滑菜單效果的實(shí)現(xiàn),一起看看吧
    2017-04-04
  • Android模擬實(shí)現(xiàn)華為系統(tǒng)升級(jí)進(jìn)度條

    Android模擬實(shí)現(xiàn)華為系統(tǒng)升級(jí)進(jìn)度條

    這篇文章主要介紹了如何通過(guò)Android模擬實(shí)現(xiàn)華為在系統(tǒng)升級(jí)時(shí)顯示的進(jìn)度條。文中的實(shí)現(xiàn)過(guò)程講解詳細(xì),感興趣的小伙伴可以動(dòng)手試一試
    2022-01-01
  • Android 列表倒計(jì)時(shí)的實(shí)現(xiàn)的示例代碼(CountDownTimer)

    Android 列表倒計(jì)時(shí)的實(shí)現(xiàn)的示例代碼(CountDownTimer)

    本篇文章主要介紹了Android 列表倒計(jì)時(shí)的實(shí)現(xiàn)的示例代碼(CountDownTimer),具有一定的參考價(jià)值,有興趣的可以了解一下
    2017-09-09
  • Android基于Service的音樂(lè)播放器

    Android基于Service的音樂(lè)播放器

    這篇文章主要為大家詳細(xì)介紹了Android基于Service的音樂(lè)播放器,本文開(kāi)發(fā)一個(gè)基于Service的音樂(lè)播放器,音樂(lè)由后臺(tái)運(yùn)行的Service負(fù)責(zé)播放,感興趣的小伙伴們可以參考一下
    2016-08-08
  • Android ViewDragHelper使用方法詳解

    Android ViewDragHelper使用方法詳解

    這篇文章主要為大家詳細(xì)介紹了Android ViewDragHelper的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-12-12

最新評(píng)論

上饶市| 武威市| 鄂托克前旗| 贡嘎县| 玉山县| 永嘉县| 当涂县| 肃南| 满洲里市| 巴彦淖尔市| 沈丘县| 伊宁县| 边坝县| 兴安县| 商南县| 芜湖市| 新野县| 涡阳县| 长春市| 郯城县| 兴化市| 利川市| 来安县| 东兴市| 军事| 临泉县| 江永县| 德阳市| 咸丰县| 永春县| 抚顺市| 治多县| 天水市| 拉孜县| 嘉义市| 昭苏县| 新郑市| 千阳县| 伊吾县| 元氏县| 卢龙县|