我正在尝试开发listview下拉列表,但是,当我运行应用程序时,我只能看到工具栏,然后带有箭头的listview,但是它不显示或不显示listview选项。请帮忙。
Second.Java 公共类PlaceActivity扩展了AppCompatActivity实现 OnItemClickListener {
public ArrayList<GetterSetter> myArrayList;
private Toolbar toolbar;
private Spinner spinner;
ListView myList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_place);
myList = (ListView) findViewById(R.id.myList);
toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);
spinner= (Spinner) findViewById(R.id.action_bar_spinner);
ArrayAdapter<CharSequence> list = ArrayAdapter.createFromResource(PlaceActivity.this, R.array.places, android.R.layout.simple_spinner_item);
list.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
}
@Override public void onItemSelected(AdapterView<?> parent, View view,int itemPosition, long itemId) {
dialog = ProgressDialog.show(this, "", "Please wait", true);
new readFromGooglePlaceAPI()
.execute("https://maps.googleapis.com/maps/api/place/nearbysearch/json?"
+ "location=53.795984,-1.759398&radius=100000&sensor=true&"
+ "key=APIKey0&types="
+ places[itemPosition]);
myList.setOnItemClickListener(this);
return true;
}
Second.XML
<LinearLayout 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"
android:orientation="vertical"
tools:context=".SecondActivity" >
<include
layout="@layout/tool_bar"
android:id="@+id/tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Spinner
android:id="@+id/spinner_toolbar"
android:layout_width="wrap_content"
android:layout_height="41dp" />
<TextView
android:id="@+id/nodata"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No data"
android:textColor="#ff3b5998"
android:textSize="18sp"
android:layout_gravity="center"/>
<ListView
android:id="@+id/myList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerHeight="5dp">
</ListView>
</LinearLayout>