0
오랫동안 해결하려고 시도한 ListView 및 ArrayAdapter에 대한 기호를 해결할 수 없습니다. 제안 plz. 고해상도/레이아웃 activity_main.xml
, fragment.xml
및 layout_textview.xml
기호 ListView 및 ArrayAdapter를 확인할 수 없습니다.
fragment.xml에게
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.sunshine.BlankFragment">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/listView"
android:layout_gravity="center_vertical" >
</ListView>
</FrameLayout>
layout_textview.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?attr/listPreferredItemHeight"
android:id="@+id/text_view">
</TextView>
BlankFragment.java
public class BlankFragment extends Fragment {
private View rootview;
private ListView listView;
private ArrayAdapter<String> itemAdapter;
public BlankFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootview= inflater.inflate(R.layout.fragment_blank, container, false);
String[] forecastArray={"Monday-sunny","Tuesday-cloudy","wednesday-sunny","Thursday-rain","friday-cloudy","saturday-sunny","sunday-cloudy"};
List<String> weekforecast=new ArrayList<String>(Arrays.asList(forecastArray));
itemAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.layout_textview,R.id.text_view, weekforecast);
listView=(ListView)rootview.findViewById(R.id.listView);
listView.setAdapter(weekforecast);
return rootview;
}
}
조각에'import' 문은 무엇입니까? –
ListView 및 ArrayAdapter에 대한 import 문을 포함시킨 후 감사합니다. –