こんにちは私はちょうどアイコンのタイトルと説明がほしいと思っています。それはビューページの一部なので断片化していますが、私はnullpointerexceptionを得ています。理由を理解できない。私のコードはこのようになり、私の他のすべてのページはうまくいきます。私は仕事に出られないだけのこのリストです。フラグメントカスタムのArrayAdapter
public class Test extends Fragment{
View view;
Context context;
public static ListView lView;
public static ArrayAdapter<String> leftList;
public class MyCustomAdapter extends ArrayAdapter<String> {
public MyCustomAdapter(Context context, int resource, int textViewResourceId, String[] dayOfWeek) {
super(context, resource, textViewResourceId, dayOfWeek);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView label=(TextView)view.findViewById(R.id.rowTextView);
label.setText(DayOfWeek[position]);
ImageView icon=(ImageView)view.findViewById(R.id.listIcon);
if (DayOfWeek[position]=="Sunday"){
icon.setImageResource(R.drawable.file);
}else{
icon.setImageResource(R.drawable.icon);
}
TextView desc = (TextView)view.findViewById(R.id.description);
if (DayOfWeek[position]=="Sunday"){
desc.setText("Description1");
}else{
desc.setText("desc");
}
return view;
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.leftlist, null);
LinearLayout pasteLayout=(LinearLayout)view.findViewById(R.id.bottomBar);
pasteLayout.setVisibility(LinearLayout.GONE);
context = getActivity();
lView = (ListView) view.findViewById(R.id.ListView01);
Test est = new Test();
Test.MyCustomAdapter teS = est.new MyCustomAdapter(context, R.layout.row, R.id.rowTextView, DayOfWeek);
leftList = teS;
lView.setAdapter(leftList);
return view;
}
String[] DayOfWeek = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
}
任意の助けをいただければ幸いですおかげでトン本当に私はこの作業を取得することができます願って、私は本当に近いと思う
E/AndroidRuntime(1304): java.lang.NullPointerException
E/AndroidRuntime(1304): at com.testing.Test$MyCustomAdapter.getView(Test.java:29)
E/AndroidRuntime(1304): at android.widget.AbsListView.obtainView(AbsListView.java:1445)
E/AndroidRuntime(1304): at android.widget.ListView.measureHeightOfChildren(ListView.java:1220)
E/AndroidRuntime(1304): at android.widget.ListView.onMeasure(ListView.java:1131)
E/AndroidRuntime(1304): at android.view.View.measure(View.java:8363)
E/AndroidRuntime(1304): at android.widget.RelativeLayout.measureChild(RelativeLayout.java:566)
E/AndroidRuntime(1304): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:381)
E/AndroidRuntime(1304): at android.view.View.measure(View.java:8363)
E/AndroidRuntime(1304): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3160)
E/AndroidRuntime(1304): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
E/AndroidRuntime(1304): at android.view.View.measure(View.java:8363)
E/AndroidRuntime(1304): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:595)
E/AndroidRuntime(1304): at android.view.View.measure(View.java:8363)
E/AndroidRuntime(1304): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3160)
E/AndroidRuntime(1304): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
E/AndroidRuntime(1304): at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
E/AndroidRuntime(1304): at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
E/AndroidRuntime(1304): at android.view.View.measure(View.java:8363)
E/AndroidRuntime(1304): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3160)
E/AndroidRuntime(1304): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
E/AndroidRuntime(1304): at android.view.View.measure(View.java:8363)
E/AndroidRuntime(1304): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3160)
E/AndroidRuntime(1304): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
E/AndroidRuntime(1304): at android.view.View.measure(View.java:8363)
E/AndroidRuntime(1304): at android.view.ViewRoot.performTraversals(ViewRoot.java:841)
E/AndroidRuntime(1304): at android.view.ViewRoot.handleMessage(ViewRoot.java:1873)
E/AndroidRuntime(1304): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(1304): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime(1304): at android.app.ActivityThread.main(ActivityThread.java:3703)
E/AndroidRuntime(1304): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(1304): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(1304): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
E/AndroidRuntime(1304): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
E/AndroidRuntime(1304): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 278): Force finishing activity com.testing/.MainActivity
W/ActivityManager( 278): Activity pause timeout for HistoryRecord{408d4540 com.testing/.MainActivity}
logcatでエラー:)