Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 我应该如何更正代码以消除这些“错误”;“未使用的值”;警告?_Android_Eclipse_Location - Fatal编程技术网

Android 我应该如何更正代码以消除这些“错误”;“未使用的值”;警告?

Android 我应该如何更正代码以消除这些“错误”;“未使用的值”;警告?,android,eclipse,location,Android,Eclipse,Location,这些是我收到的错误信息,请告知 未使用字段LocationListActivity.adapter的值 public class LocationListActivity extends ExpandableListActivity { private ArrayAdapter<String> adapter = null; private String name; private ArrayList<List<LocationData>> location

这些是我收到的错误信息,请告知

未使用字段LocationListActivity.adapter的值

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;
}
未使用字段LocationListActivity.lv1的值

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;
}
未使用字段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;
}
公共类LocationListActivity扩展了ExpandableListActivity{
专用ArrayAdapter适配器=null;
私有字符串名称;
私有ArrayList位置;//所有位置的数组列表
私有ArrayList locationList;//每个组的位置
私有ListView lv1;
private ArrayList locationSection=新建ArrayList();
private ArrayList sectionLocations=new ArrayList();
private ArrayList allLocations=new ArrayList();
私人字符串标题;
私有可扩展列表适配器mAdapter;
私人按钮搜索;
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.location\u list\u活动);
search=(按钮)findviewbyd(R.id.search_按钮);
search.setOnClickListener(新的OnClickListener(){
公共void onClick(视图v){
startActivity(新意图(LocationListActivity.this、LocationListSearchActivity.class));
}
});
//解析locations.xml
试试{
this.locations=新的ArrayList();
this.locationList=新的ArrayList();
XmlResourceParser xrp=this.getResources().getXml(R.xml.locations);
LocationData currentLocation=null;
while(xrp.getEventType()!=XmlResourceParser.END_文档){
currentLocation=新位置数据();
if(xrp.getEventType()==XmlResourceParser.START_标记){
if(xrp.getName().equals(“节”)){
locationSection.add(xrp.getAttributeValue(null,“title”);
} 
else if(xrp.getName().equals(“位置”)){
currentLocation.setBuilding((xrp.getAttributeValue(null,“building”));
name=xrp.getAttributeValue(null,“name”);
节位置。添加(名称);
currentLocation.setName(名称);
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(当前位置);
}
}
else if(xrp.getEventType()==XmlResourceParser.END_标记){
if(xrp.getName().equals(“节”)){
添加(新的ArrayList(sectionLocations));
sectionLocations.clear();
添加(新的ArrayList(locationList));
locationList.clear();
}
}
xrp.next();
}   
xrp.close();}
catch(XmlPullParserException xppe){}
捕获(IOE){}
//设置适配器
mAdapter=新的MyExpandableListAdapter();
setListAdapter(mAdapter);
}
公共类MyExpandableListAdapter扩展了BaseExpandableListAdapter{
公共对象getChild(int-groupPosition,int-childPosition){
返回allLocations.get(groupPosition).get(childPosition);
}
公共长getChildId(int-groupPosition,int-childPosition){
返回子位置;
}
公共整数getChildrenCount(整数组位置){
返回allLocations.get(groupPosition.size();
}
公共文本视图getGenericView(){
//ExpandableListView的布局参数
AbsListView.LayoutParams lp=新的AbsListView.LayoutParams(
ViewGroup.LayoutParams.FILL_父对象,80);
TextView TextView=新的TextView(LocationListActivity.this);
textView.setLayoutParams(lp);
//将文本垂直居中
textView.setGravity(Gravity.CENTER|u VERTICAL | Gravity.LEFT);
//设置文本起始位置
textView.setBackgroundResource(R.drawable.button\u click);
setTypeface(null,android.graphics.Typeface.BOLD);
textView.setTextColor(0xFF000000);
setPadding(55,0,0,0);
返回文本视图;
}
公共视图getChildView(int-groupPosition、int-childPosition、boolean-isLastChild、,
视图(视图、视图组父级){
TextView TextView=getGenericView();
setText(getChild(groupPosition,childPosition.toString());
setTypeface(null,android.graphics.Typeface.NORMAL);
返回文本视图;
}
公共对象getGroup(int-groupPosition){
返回位置section.get(groupPosition);
}
public int getGroupCount(){
返回位置section.size();
}
公共长getGroupId(int-groupPosition){
返回组位置;
}
公共视图getGroupView(int-groupPosition、布尔值isExpanded、视图convertView、,
视图组(父级){
TextView TextView=getGenericView();
setText(getGroup(groupPosition.toString());
返回文本视图;
}
公共布尔值isChildSelectable(int-groupPosition,int-childPosition){
返回true;
}
公共布尔表ID(){
返回true;
}
}
公共布尔onChildClick(ExpandableListView父视图、视图v、int-groupPosition、int-childPosition、长id){
意图i=新意图(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());