谁能告诉我这个 logcat 的要求是什么?
建议请。
感谢您宝贵的时间!..
站适配器
public class StationAdapter extends ArrayAdapter<Stations> {
Context context;
List<Stations> originalList;
List<Stations> temp;
private StationFilter filter;
public StationAdapter(Context context, int textViewResourceId,
List<Stations> objects) {
super(context, textViewResourceId, objects);
this.context = context ;
this.originalList = new ArrayList<Stations>();
this.originalList.addAll(objects);
this.temp = new ArrayList<Stations>();
this.temp.addAll(objects);
}
@Override
public Filter getFilter() {
if (filter == null){
filter = new StationFilter();
}
return filter;
}
private class ViewHolder {
TextView name;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ViewHolder holder = null;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.station_child, null);
holder = new ViewHolder();
holder.name = (TextView) convertView.findViewById(R.id.textView_single_item);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
Stations stations =originalList.get(position);
holder.name.setText(stations.station_name);
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
tab_detailsActivity.weatherData=null;
System.out.println("adap "+ originalList.get(position).station_name+" "+originalList.get(position).station_code);
Stations station=originalList.get(position);
if(station.isCamera){
Intent intent =new Intent(context,TabhostActivity.class);
intent.putExtra("station_code", station.station_code);
intent.putExtra("station_name", station.station_name);
intent.putExtra("isCamera", "YES");
context.startActivity(intent);
}else{
Intent txt_det_intent = new Intent(context, tab_detailsActivity.class);
txt_det_intent.putExtra("station_code", station.station_code);
txt_det_intent.putExtra("station_name", station.station_name);
txt_det_intent.putExtra("isCamera", "NO");
context.startActivity(txt_det_intent);
}
}
});
return convertView;
}
private class StationFilter extends Filter
{
@Override
protected FilterResults performFiltering(CharSequence constraint) {
constraint = constraint.toString().toLowerCase();
FilterResults result = new FilterResults();
if(constraint != null && constraint.toString().length() > 0)
{
ArrayList<Stations> filteredItems = new ArrayList<Stations>();
for(int i = 0, l = temp.size(); i < l; i++)
{
Stations stations= temp.get(i);
if(stations.station_name.toString().toLowerCase().startsWith(constraint.toString()))
filteredItems.add(stations);
}
result.count = filteredItems.size();
result.values = filteredItems;
}
else
{
synchronized(this)
{
result.values = temp;
result.count = temp.size();
}
}
return result;
}
@SuppressWarnings("unchecked")
@Override
protected void publishResults(CharSequence constraint,
FilterResults results) {
originalList = (ArrayList<Stations>)results.values;
notifyDataSetChanged();
clear();
for(int i = 0, l = originalList.size(); i < l; i++)
add(originalList.get(i));
notifyDataSetInvalidated();
}
}}
**Logcat**
06-07 16:44:46.850: E/AndroidRuntime(21145): FATAL EXCEPTION: main
06-07 16:44:46.850: E/AndroidRuntime(21145): java.lang.NullPointerException
06-07 16:44:46.850: E/AndroidRuntime(21145): at org.twinkle.weather.StationAdapter.getView(StationAdapter.java:70)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.AbsListView.obtainView(AbsListView.java:2472)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.ListView.makeAndAddView(ListView.java:1775)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.ListView.fillDown(ListView.java:678)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.ListView.fillFromTop(ListView.java:739)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.ListView.layoutChildren(ListView.java:1628)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.AbsListView.onLayout(AbsListView.java:2307)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.View.layout(View.java:14072)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.ViewGroup.layout(ViewGroup.java:4657)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.View.layout(View.java:14072)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.ViewGroup.layout(ViewGroup.java:4657)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.View.layout(View.java:14072)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.ViewGroup.layout(ViewGroup.java:4657)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.View.layout(View.java:14072)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.ViewGroup.layout(ViewGroup.java:4657)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.View.layout(View.java:14072)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.ViewGroup.layout(ViewGroup.java:4657)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.View.layout(View.java:14072)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.ViewGroup.layout(ViewGroup.java:4657)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2004)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1825)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1120)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4604)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.Choreographer.doFrame(Choreographer.java:525)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.os.Handler.handleCallback(Handler.java:615)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.os.Handler.dispatchMessage(Handler.java:92)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.os.Looper.loop(Looper.java:137)
06-07 16:44:46.850: E/AndroidRuntime(21145): at android.app.ActivityThread.main(ActivityThread.java:4921)
06-07 16:44:46.850: E/AndroidRuntime(21145): at java.lang.reflect.Method.invokeNative(Native Method)
06-07 16:44:46.850: E/AndroidRuntime(21145): at java.lang.reflect.Method.invoke(Method.java:511)
06-07 16:44:46.850: E/AndroidRuntime(21145): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
06-07 16:44:46.850: E/AndroidRuntime(21145): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
06-07 16:44:46.850: E/AndroidRuntime(21145): at dalvik.system.NativeStart.main(Native Method)