/*
* Copyright (c) 2014. Marshal Chen.
*/
package com.marshalchen.common.demoofui.fadingactionbar;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.marshalchen.common.demoofui.R;
import com.marshalchen.common.uimodule.fadingactionbar.FadingActionBarHelper;
public class HeaderOverlayActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FadingActionBarHelper helper = new FadingActionBarHelper()
.actionBarBackground(R.drawable.fading_actionbar_ab_background)
.headerLayout(R.layout.fading_actionbar_header)
.contentLayout(R.layout.fading_actionbar_activity_listview)
.headerOverlayLayout(R.layout.fading_actionbar_header_overlay);
setContentView(helper.createView(this));
helper.initActionBar(this);
ListView listView = (ListView) findViewById(android.R.id.list);
ArrayList<String> items = loadItems(R.raw.nyc_sites);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items);
listView.setAdapter(adapter);
}
/**
* @return A list of Strings read from the specified resource
*/
private ArrayList<String> loadItems(int rawResourceId) {
try {
ArrayList<String> countries = new ArrayList<String>();
InputStream inputStream = getResources().openRawResource(rawResourceId);
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = reader.readLine()) != null) {
countries.add(line);
}
reader.close();
return countries;
} catch (IOException e) {
return null;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.fading_actionbar_activity_menu, menu);
return true;
}
}