小编IBu*_*nny的帖子

在微调器中无法选择项目(自定义微调器适配器)

我在Android应用程序中使用自定义spinner适配器颜色spinner.下拉工作正常.但是一旦我从微调器中选择了一个颜色(项目),它就不可选择了.此外,我不需要显示所选项目.我只想识别所选颜色而不显示它.

下面是我的CustomSpinnerAdapter的代码:

@Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
        TextView rowView=null;
        if(convertView == null){
            convertView=inflater.inflate(R.layout.spinner_layout, null);
        }
        rowView=(TextView) convertView.findViewById(R.id.spinnerColorview);
        rowView.setBackgroundColor(Color.parseColor(itemList.get(position)));

        return convertView;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TextView rowView=null;
        if(convertView == null){
            convertView=inflater.inflate(R.layout.spinner_layout, null);
        }
        rowView=(TextView) convertView.findViewById(R.id.spinnerColorview);
        rowView.setBackgroundColor(Color.parseColor(itemList.get(position)));

        return convertView;

    }
Run Code Online (Sandbox Code Playgroud)

EDIT: 更多信息

我在spinner中的下拉列表无法选择.当我点击微调器时,它显示列表.但是当我从该列表中选择一个项目时,没有任何反应.我无法识别所选项目.

当我在getView(int position, View convertView, ViewGroup parent)方法内部打印位置时,它会打印所有项目ID.

我只需要识别所选项目,我不需要像通常那样在旋转器的顶部显示它.这是我的spinner_layout.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="40dp"
    android:clickable="true"
    android:orientation="horizontal"
    android:paddingLeft="40dp"
    tools:context=".MainActivity" >

    <TextView …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-spinner

6
推荐指数
2
解决办法
3620
查看次数

android和native android(Android NDK)有什么区别?

我是android开发的新手。我读了一些关于android的文章。但我不正确理解android和android NDK有什么区别。当我们使用除常规android开发资源以外的android NDK时该怎么办?

java android

3
推荐指数
2
解决办法
2111
查看次数

如何替换 CheckedTextView 中的“android:drawableLeft”图像

我使用“android:drawableLeft”在布局中设置图像图标。这是我的布局代码:

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/textView1"
    android:layout_marginLeft="8dp"
    android:drawableLeft="@drawable/ic_launcher"
    android:gravity="left"/> 
Run Code Online (Sandbox Code Playgroud)

我需要做的是,使用我的课程将此图像更改为其他图像。这是我在使用 BaseExpandableListAdapter 扩展的 Adapter 类中使用的代码。

if (convertView == null) {
convertView = inflater.inflate(R.layout.listrow_details, null);
}
((CheckedTextView) convertView).setCheckMarkDrawable(R.drawable.ic_folder);
Run Code Online (Sandbox Code Playgroud)

但这不是替换使用过的图像。相反,替换它被添加到同一行。我应该怎么做才能用新图像替换当前图像?

android checkedtextview android-layout

3
推荐指数
1
解决办法
3560
查看次数

如何检测android双击?

如何检测android中的双击?我实现了OnDoubleTapListener并写了这个:

public boolean onDoubleTapEvent(MotionEvent e) {
        // TODO Auto-generated method stub
        if(e.getAction() == 1){
            Toast.makeText(getApplicationContext(),"Double Tap", Toast.LENGTH_SHORT).show();
        }
        return true;
    }
Run Code Online (Sandbox Code Playgroud)

但它没有用.这有什么不对?

android tap double-click

2
推荐指数
1
解决办法
8480
查看次数