我正在尝试从我的代码访问listview和textview,我在互联网上阅读了很多帖子,但我找不到任何适合我的帖子。 我有一个这样的空白片段:
public class MyFrag extends Fragment {
//My Code
List<String> Names = new ArrayList<String>();
List<Double> Prices = new ArrayList<Double>();
List<String> Dates = new ArrayList<String>();
List<String> Hours = new ArrayList<String>();
List<String> iDs = new ArrayList<String>();
Double TotalMy = 0.00;
SimpleAdapter adapter;
public MyFrag() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
//RelativeLayout rootView = (RelativeLayout) inflater.inflate(R.layout.fragment_my_frag, container, false);
//View view = inflater.inflate(R.layout.fragment_my_frag, container, false);
LayoutInflater lf = getActivity().getLayoutInflater();
View view = lf.inflate(R.layout.fragment_my_frag, container, false);
ListView listview = (ListView) getView().findViewById(R.id.list);
TextView textTotalMy = (TextView) getView().findViewById(R.id.textTotalMy1);
return view;
}
但是当我打开片段时,应用程序崩溃了。
请帮帮我
答案 0 :(得分:0)
我通过编程方式创建相同的相对布局来解决它