If you think the Android project GreenDroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright (C) 2010 Cyril Mottier (http://www.cyrilmottier.com)
*//fromwww.java2s.com
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.cyrilmottier.android.gdcatalog;
import greendroid.app.GDActivity;
import greendroid.widget.ActionBarItem;
import greendroid.widget.LoaderActionBarItem;
import greendroid.widget.ActionBarItem.Type;
import greendroid.widget.NormalActionBarItem;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.TextView;
import android.widget.Toast;
publicclass ActionBarActivity extends GDActivity {
privatefinal Handler mHandler = new Handler();
@Override
protectedvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setActionBarContentView(R.layout.text);
((TextView) findViewById(R.id.text)).setText(R.string.first_screen);
addActionBarItem(Type.Refresh, R.id.action_bar_refresh);
addActionBarItem(getActionBar()
.newActionBarItem(NormalActionBarItem.class)
.setDrawable(R.drawable.ic_title_export)
.setContentDescription(R.string.gd_export), R.id.action_bar_export);
addActionBarItem(Type.Locate, R.id.action_bar_locate);
}
@Override
publicboolean onHandleActionBarItemClick(ActionBarItem item, int position) {
switch (item.getItemId()) {
case R.id.action_bar_locate:
startActivity(new Intent(this, TabbedActionBarActivity.class));
break;
case R.id.action_bar_refresh:
final LoaderActionBarItem loaderItem = (LoaderActionBarItem) item;
mHandler.postDelayed(new Runnable() {
publicvoid run() {
loaderItem.setLoading(false);
}
}, 2000);
Toast.makeText(this, R.string.refresh_pressed, Toast.LENGTH_SHORT).show();
break;
case R.id.action_bar_export:
Toast.makeText(this, R.string.custom_drawable, Toast.LENGTH_SHORT).show();
break;
default:
return super.onHandleActionBarItemClick(item, position);
}
return true;
}
}