15-11-1395، 12:59 ب.ظ
سلام و خسته نباشید
من توی یک فرگمنت یه Listview دارم که میخوام بغل هر سطرش یک TextView بذارم،این کد رو دارم اما اجرا نمیشه و موقع اجرا خطا میده
اینم خطاهاش:
من توی یک فرگمنت یه Listview دارم که میخوام بغل هر سطرش یک TextView بذارم،این کد رو دارم اما اجرا نمیشه و موقع اجرا خطا میده
public class fragment2 extends Fragment { private ArrayList<String> strings = new ArrayList<>(); public ListView lst; private Context context1; private DatabaseHandler db; private String[] names = new String[]{"ali" , "ali " ,"ali"}; @Nullable @Override public View onCreateView(final LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment2, container, false); lst = (ListView) v.findViewById(R.id.lst); set(); return v; } private void set() { db = new DatabaseHandler(getContext()); db.open(); strings = db.arrayList(); db.close(); lst.setAdapter(new aa(getContext())); } class aa extends ArrayAdapter<String>{ public aa(Context context){ super(context , R.layout.row ,names); context1 = context; } @NonNull @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) context1.getSystemService(context1.LAYOUT_INFLATER_SERVICE); View row = inflater.inflate(R.layout.row , parent); TextView txt = (TextView) row.findViewById(R.id.txt2); return row; } } }
اینم خطاهاش:
FATAL EXCEPTION: main Process: com.irprogram.ahbottomnavigation, PID: 3268 java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView at android.widget.AdapterView.addView(AdapterView.java:487) at android.view.LayoutInflater.inflate(LayoutInflater.java:512) at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) at android.view.LayoutInflater.inflate(LayoutInflater.java:414) at android.view.LayoutInflater.inflate(LayoutInflater.java:365) at com.irprogram.ahbottomnavigation.fragment2$aa.getView(fragment2.java:55) at android.widget.AbsListView.obtainView(AbsListView.java:2347) at android.widget.ListView.makeAndAddView(ListView.java:1864) at android.widget.ListView.fillDown(ListView.java:698) at android.widget.ListView.fillFromTop(ListView.java:759) at android.widget.ListView.layoutChildren(ListView.java:1673) at android.widget.AbsListView.onLayout(AbsListView.java:2151) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557) at android.widget.LinearLayout.onLayout(LinearLayout.java:1466) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1767) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1087) at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:797) at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:811) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:433) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557) at android.widget.LinearLayout.onLayout(LinearLayout.java:1466) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579) at android.widget.FrameLayout.onLayout(FrameLayout.java:514) at android.view.View.layout(View.java:15671) at android.view.ViewGroup.layout(ViewGroup.java:5038) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2086) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1843) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) at android.view.Choreographer.doCallbacks(Choreographer.java:580) at android.view.Choreographer.doFrame(Choreographer.java:550) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteIni