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