Skip to content

Commit

Permalink
add backnavigation
Browse files Browse the repository at this point in the history
  • Loading branch information
xpbtmusic committed Feb 27, 2013
1 parent 6dd20bb commit da445cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Binary file modified bin/classes/com/example/mynews/MainActivity.class
Binary file not shown.
15 changes: 14 additions & 1 deletion src/com/example/mynews/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@



import com.actionbarsherlock.app.ActionBar.OnMenuVisibilityListener;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.widget.SearchView;
Expand All @@ -36,6 +37,7 @@
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;

public class MainActivity extends Activity implements OnPageChangeListener{

Expand All @@ -60,7 +62,17 @@ protected void onCreate(Bundle savedInstanceState) {
if(1==position){
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

findViewById(android.R.id.home).setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
if(null!=mIndicator){
mIndicator.setCurrentItem(0);
}


}
});
handler = new Handler(new Handler.Callback() {

@Override
Expand Down Expand Up @@ -187,6 +199,7 @@ public void onPageScrolled(int arg0, float arg1, int arg2) {

@Override
public void onPageSelected(int position) {

getSupportActionBar().setTitle(mAdapter.getPageTitle(position));
if(0==position){
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
Expand Down

0 comments on commit da445cd

Please sign in to comment.