0
我使用简单的游标适配器填写sherlockListFragment名单。我这样做了与loaders.But当我试图颜色在列表中添加到文本。我是越来越Java.lang.Null.pointer exception.And我的Java代码颜色设置到该项目中listFragment
@Override
public void onActivityCreated(Bundle savedInstanceState) {
Log.i("live", "onActivityCreated");
super.onActivityCreated(savedInstanceState);
setEmptyText("Loading...");
SimpleCursorAdapter.ViewBinder vb=new SimpleCursorAdapter.ViewBinder() {
@Override
public boolean setViewValue(View arg0, Cursor arg1, int arg2) {
Log.i("alls","inside set View Value");
View inflate=getActivity().getLayoutInflater().inflate(R.layout.live_list_stock,null);
TextView tv=(TextView)inflate.findViewById(R.id.lpercent);
tv.setTextColor(Color.RED);
//String i=tv.getText().toString();
//Log.i("alls",(i));
// TODO Auto-generated method stub
return true;
}
};
liveMyStocksadapter = new SimpleCursorAdapter(getActivity().getApplicationContext(), R.layout.live_list_item, null, new String[] {DBConstants.NAME,DBConstants.YSYMBOL,DBConstants.PRICE,DBConstants.PERCENT,DBConstants.DATE,DBConstants.TIME,DBConstants.OPEN,DBConstants.HIGH,DBConstants.LOW,DBConstants.VOLUME}, new int[] {R.id.lname,R.id.lysymbol, R.id.lprice,R.id.lpercent,R.id.ldate,R.id.ltime,R.id.lopen,R.id.lhigh,R.id.llow,R.id.lvolume},0);
setListAdapter(liveMyStocksadapter);
mycontext=this;
getActivity().registerReceiver(FragmentReceiver1, new IntentFilter("fragmentupdater"));
getActivity().getSupportLoaderManager().initLoader(0, null, this);
liveMyStocksadapter.setViewBinder(vb);
感谢您的帮助..
你可以把堆栈跟踪 – DjHacktorReborn 2013-03-07 10:16:20