这些是我收到的错误消息,请告知。
未使用字段 LocationListActivity.adapter 的值
未使用字段 LocationListActivity.lv1 的值
未使用字段 LocationListActivity.titleString 的值
public class LocationListActivity extends ExpandableListActivity {
private ArrayAdapter<String> adapter = null;
private String name;
private ArrayList<List<LocationData>> locations; //Array list of all locations
private ArrayList<LocationData> locationList; // locations for each group
private ListView lv1;
private ArrayList<String> locationSection = new ArrayList<String>();
private ArrayList<String> sectionLocations = new ArrayList<String>();
private ArrayList<ArrayList<String>> allLocations = new ArrayList<ArrayList<String>>();
private String titleString;
private ExpandableListAdapter mAdapter;
private Button search;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location_list_activity);
search = (Button)findViewById(R.id.search_button);
search.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
startActivity(new Intent(LocationListActivity.this, LocationListSearchActivity.class));
}
});
//PARSE locations.xml
try {
this.locations = new ArrayList<List<LocationData>>();
this.locationList = new ArrayList<LocationData>();
XmlResourceParser xrp = this.getResources().getXml(R.xml.locations);
LocationData currentLocation = null;
while(xrp.getEventType() != XmlResourceParser.END_DOCUMENT) {
currentLocation = new LocationData();
if(xrp.getEventType() == XmlResourceParser.START_TAG) {
if(xrp.getName().equals("section")) {
locationSection.add(xrp.getAttributeValue(null, "title"));
}
else if(xrp.getName().equals("location")) {
currentLocation.setBuilding((xrp.getAttributeValue(null, "building")));
name = xrp.getAttributeValue(null, "name");
sectionLocations.add(name);
currentLocation.setName(name);
currentLocation.setDetailName((xrp.getAttributeValue(null, "detailName")));
currentLocation.setLat(Double.parseDouble(xrp.getAttributeValue(null, "lat")));
currentLocation.setLng(Double.parseDouble(xrp.getAttributeValue(null, "lng")));
currentLocation.setPhone(xrp.getAttributeValue(null, "phone"));
locationList.add(currentLocation);
}
}
else if(xrp.getEventType() == XmlResourceParser.END_TAG) {
if(xrp.getName().equals("section")) {
allLocations.add(new ArrayList<String>(sectionLocations));
sectionLocations.clear();
locations.add(new ArrayList<LocationData>(locationList));
locationList.clear();
}
}
xrp.next();
}
xrp.close();}
catch (XmlPullParserException xppe) {}
catch (IOException e) {}
// Set up our adapter
mAdapter = new MyExpandableListAdapter();
setListAdapter(mAdapter);
}
public class MyExpandableListAdapter extends BaseExpandableListAdapter {
public Object getChild(int groupPosition, int childPosition) {
return allLocations.get(groupPosition).get(childPosition);
}
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
public int getChildrenCount(int groupPosition) {
return allLocations.get(groupPosition).size();
}
public TextView getGenericView() {
// Layout parameters for the ExpandableListView
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, 80);
TextView textView = new TextView(LocationListActivity.this);
textView.setLayoutParams(lp);
// Center the text vertically
textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
// Set the text starting position
textView.setBackgroundResource(R.drawable.button_click);
textView.setTypeface(null, android.graphics.Typeface.BOLD);
textView.setTextColor(0xFF000000);
textView.setPadding(55, 0, 0, 0);
return textView;
}
public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
View convertView, ViewGroup parent) {
TextView textView = getGenericView();
textView.setText(getChild(groupPosition, childPosition).toString());
textView.setTypeface(null, android.graphics.Typeface.NORMAL);
return textView;
}
public Object getGroup(int groupPosition) {
return locationSection.get(groupPosition);
}
public int getGroupCount() {
return locationSection.size();
}
public long getGroupId(int groupPosition) {
return groupPosition;
}
public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
ViewGroup parent) {
TextView textView = getGenericView();
textView.setText(getGroup(groupPosition).toString());
return textView;
}
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
public boolean hasStableIds() {
return true;
}
}
public boolean onChildClick (ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
Intent i = new Intent( LocationListActivity.this, LocationInfoActivity.class );
i.putExtra("name", locations.get(groupPosition).get(childPosition).getName());
i.putExtra("building", locations.get(groupPosition).get(childPosition).getBuilding());
i.putExtra("detailName", locations.get(groupPosition).get(childPosition).getDetailName());
i.putExtra("lat", locations.get(groupPosition).get(childPosition).getLat());
i.putExtra("lng", locations.get(groupPosition).get(childPosition).getLng());
i.putExtra("phone", locations.get(groupPosition).get(childPosition).getPhone());
startActivity(i);
return false;
}
@Override
public boolean onCreateOptionsMenu(Menu menu){
MenuInflater inflater = this.getMenuInflater();
inflater.inflate(R.menu.menu_home, menu);
return true;
}
//Called when user selects a menu item;
@Override
public boolean onOptionsItemSelected( MenuItem item ){
switch(item.getItemId()) {
case R.id.menu_search:
startActivity(new Intent(this, LocationListSearchActivity.class));
finish();
break;
case R.id.menu_about:
startActivity(new Intent(this, AboutActivity.class));
finish();
break;
}
return true;
}
}