我复制了Universal Image Loader的代码并进行了一些调整
但是当我放置工具栏时,后面的导航没有显示
这是代码。
我也可以使用UIL进行多种图像选择吗?
感谢。
package com.thesis.juandirection.juandirectionfinale;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import com.thesis.juandirection.juandirectionfinale.fragments.ImageGridFragment;
import com.thesis.juandirection.juandirectionfinale.fragments.ImageListFragment;
import com.thesis.juandirection.juandirectionfinale.fragments.ImageGalleryFragment;
import com.thesis.juandirection.juandirectionfinale.fragments.ImagePagerFragment;
import com.thesis.juandirection.juandirectionfinale.review.reviewView;
public class SimpleImageActivity extends AppCompatActivity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fr_image_grid);
Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("Review: Bulacan State University");
int frIndex = getIntent().getIntExtra(Constants.Extra.FRAGMENT_INDEX, 0);
Fragment fr;
String tag;
int titleRes;
switch (frIndex) {
default:
case ImageListFragment.INDEX:
tag = ImageListFragment.class.getSimpleName();
fr = getSupportFragmentManager().findFragmentByTag(tag);
if (fr == null) {
fr = new ImageListFragment();
}
titleRes = R.string.ac_name_image_list;
break;
case ImageGridFragment.INDEX:
tag = ImageGridFragment.class.getSimpleName();
fr = getSupportFragmentManager().findFragmentByTag(tag);
if (fr == null) {
fr = new ImageGridFragment();
}
titleRes = R.string.ac_name_image_grid;
break;
case ImagePagerFragment.INDEX:
tag = ImagePagerFragment.class.getSimpleName();
fr = getSupportFragmentManager().findFragmentByTag(tag);
if (fr == null) {
fr = new ImagePagerFragment();
fr.setArguments(getIntent().getExtras());
}
titleRes = R.string.ac_name_image_pager;
break;
case ImageGalleryFragment.INDEX:
tag = ImageGalleryFragment.class.getSimpleName();
fr = getSupportFragmentManager().findFragmentByTag(tag);
if (fr == null) {
fr = new ImageGalleryFragment();
}
titleRes = R.string.ac_name_image_gallery;
break;
}
setTitle(titleRes);
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, fr, tag).commit();
}
/*public void goBack(View view){
startActivity(new Intent(getApplicationContext(), reviewView.class));
}*/
}
XML ..
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context="com.example.directioner.newjd.MainActivity">
<include
android:id="@+id/app_bar"
layout="@layout/app_bar" />
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/grid"
android:layout_below="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:horizontalSpacing="4dip"
android:numColumns="3"
android:padding="4dip"
android:stretchMode="columnWidth"
android:verticalSpacing="4dip" />
</RelativeLayout>
</FrameLayout>
</RelativeLayout>
我的AndroidManifest。
<activity
android:name=".SimpleImageActivity"
android:label="@string/title_activity_simple_image"
android:theme="@style/AppTheme" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".review.reviewView" />
</activity>
我错过了什么? 提前谢谢,
答案 0 :(得分:0)
您缺少 getSupportActionBar()。setHomeButtonEnabled(true)。有关更多信息,请浏览Adding backbutton on top of child element of Toolbar