抱歉我的英文。我花了几倍的时间尝试修复我的问题,但我无法做到。我有listView,在这个列表视图中为一些元素创建微调器。 Spinner在适配器中创建。我不能得到价值微调。它对我来说很难。请healp
我的适配器
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_marginBottom="5dp"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/bgchilddevice"
android:layout_width="match_parent"
android:layout_weight="0.3"
android:layout_marginLeft="5dp"
android:background="#26ffffff"
android:layout_marginRight="2.5dp"
android:layout_height="60dp">
<TextView
android:id="@+id/textChild"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#fff"
android:textSize="18dp"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/bg_button_screen"
android:layout_weight="0.9"
android:layout_marginRight="5dp"
android:background="#4fcc54"
android:layout_width="match_parent"
android:layout_marginLeft="2.5dp"
android:layout_height="60dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/check"
android:id="@+id/imageView6"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:orientation="horizontal"
android:background="#26ffffff"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/spinnerL"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_weight="0.2"
android:layout_centerHorizontal="true" />
<RelativeLayout
android:id="@+id/spinnerOpen"
android:layout_width="match_parent"
android:layout_marginRight="5dp"
android:layout_weight="0.8"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/spinnerImage"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
来自适配器的我的xml
create.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
for(int i = 0; i < listView.getAdapter().getCount(); i++ ) {
for(int j = 0; j < listView.getChildCount(); j++ ) {
View _mainView = listView.getChildAt(j);
LinearLayout _linearLayout = (LinearLayout) _mainView.findViewById(R.id.spinnerL);
Spinner spinner = (Spinner) _linearLayout.getChildAt(0);
String selection = (String) spinner.getSelectedItem();
Log.e("spinner device", selection);
}
}
}
});
我尝试获取微调元素
FATAL EXCEPTION: main java.lang.NullPointerException
我有
Spinner spinner = (Spinner) _linearLayout.getChildAt(0);
在Spinner spinner = (Spinner) _linearLayout.getChildAt(0);
行
我尝试写
Spinner spinner = (Spinner) _linearLayout.getChildAt(1);
Spinner spinner = (Spinner) _linearLayout.getChildAt(2);
Spinner spinner = (Spinner) _linearLayout.getChildAt(3);
select
sum(case value1 when 99999 then valueA else 0 end) as [Value 1],
(sum(case value2 when 99999 then valueB else 0 end)) / (sum(case value1 when 99999 then valueA else 1 end)) as [Value 2]
错误
答案 0 :(得分:0)
为什么不将findViewById()
用于微调器?
Spinner spinner =(Spinner) findViewById(R.id.spinnerL);
String value = spinner.getSelectedItem().toString();
答案 1 :(得分:0)
我不知道它是不是坏代码,我尝试写这样的和它的工作!!!
setInterval(function() {
if (!$('#clients_carousel ul').is(':animated')) {
var fWidth = parseInt($('#clients_carousel ul li:first').outerWidth(true), 10);
var lIndent = parseInt($('#clients_carousel ul').css("left"), 10);
if (fWidth < Math.abs(lIndent)) {
$('#clients_carousel ul li:last').after($('#clients_carousel ul li:first'));
var newIndent = lIndent + fWidth;
$('#clients_carousel ul').css('left', newIndent + 'px');
lIndent = newIndent;
}
$('#clients_carousel ul').animate({
left: lIndent - 5
}, 40, "linear");
}
}, 41);