gpt4 book ai didi

java - 单击时 Android 微调器不显示

转载 作者:太空宇宙 更新时间:2023-11-04 11:52:40 25 4
gpt4 key购买 nike

大家好,我正在做一个程序,它有一个过滤器旋转器,旋转器将下拉并显示过滤器类型,但现在旋转器不显示任何内容。你们能帮我吗?我似乎找不到代码的问题........

这里是java

public class SpinnerInfo extends MainProduct {
Spinner spinners;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
spinners = (Spinner) findViewById(R.id.spinnertype);
final ArrayAdapter adapter = ArrayAdapter.createFromResource(this, R.array.type_arrays, R.layout.support_simple_spinner_dropdown_item);
adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
spinners.setAdapter(adapter);
spinners.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String [] dataArray = getResources().getStringArray(R.array.type_arrays);
String type = dataArray[position];}

@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}}

XML

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
android:orientation="vertical"
android:elevation="1dp"
android:weightSum="1">

<TextView
android:text="Product List"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:textSize="24sp"
android:textStyle="normal|italic"
android:textAlignment="center"
android:fontFamily="casual"
android:textColor="@android:color/background_dark"
android:layout_marginTop="10dp"/>

<TextView
android:text="Select Type:"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/textView2"
android:textAlignment="textStart"
android:textStyle="normal|bold"
android:layout_marginLeft="10dp" />

<Spinner
android:layout_width="126dp"
android:layout_height="wrap_content"
android:id="@+id/spinnertype"
android:layout_marginLeft="10dp" />

<ListView
android:id="@+id/listview_product"
android:layout_width="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:divider="@android:color/darker_gray"
android:dividerHeight="8dp"
android:background="@android:color/white"
android:layout_height="match_parent">

</ListView>

最佳答案

通过将代码移至我的主目录来解决 Qn。

关于java - 单击时 Android 微调器不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41659428/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com