我试图在textview上显示微调器的选定值,但我没有显示任何内容,我不明白问题是什么,我在onclick中使用itemselected侦听器,我不明白什么是错了有人请帮助
package com.vedicrishiastro.kundli.Screens.Extras;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.internal.widget.AdapterViewCompat;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.vedicrishiastro.kundli.R;
import com.vedicrishiastro.kundli.Screens.AbstractActivity;
public class Settings extends AbstractActivity implements View.OnClickListener {
private LinearLayout linearSelectLang,linearSetDefault,linearSelectPanch;
private TextView txtSelectLang,txtSetDefault,txtSelectPanch;
private Spinner spinner1,spinner2,spinner3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
linearSelectLang = (LinearLayout)findViewById(R.id.LinearSelectLang);
linearSetDefault = (LinearLayout)findViewById(R.id.LinearSetDefault);
linearSelectPanch = (LinearLayout)findViewById(R.id.LinearSelectPanch);
spinner1 = (Spinner)findViewById(R.id.settingSpinner1);
spinner2 = (Spinner)findViewById(R.id.settingSpinner2);
spinner3 = (Spinner)findViewById(R.id.settingSpinner3);
txtSelectLang = (TextView)findViewById(R.id.selectLangtext);
txtSetDefault = (TextView)findViewById(R.id.setdefaulttext);
txtSelectPanch = (TextView)findViewById(R.id.selectPanchtext);
linearSelectLang.setOnClickListener(this);
linearSetDefault.setOnClickListener(this);
linearSelectPanch.setOnClickListener(this);
spinner1.setVisibility(View.GONE);
spinner2.setVisibility(View.GONE);
spinner3.setVisibility(View.GONE);
spinner1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if(position == 0){
txtSelectLang.setText("English");
}
else
{
txtSelectLang.setText("Hindi");
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
public void onClick(View view){
int id = view.getId();
switch (id){
case R.id.LinearSelectLang:
{
spinner1.performClick();
}
break;
case R.id.LinearSetDefault:
{
spinner2.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch(position){
case 0:txtSetDefault.setText("Kundli");break;
case 1:txtSetDefault.setText("Panchang");break;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
spinner2.performClick();
spinner2.setVisibility(View.GONE);
}
break;
case R.id.LinearSelectPanch:
{
spinner3.performClick();
String text = spinner3.getSelectedItem().toString();
txtSelectPanch.setText(text);
spinner3.setVisibility(View.GONE);
}
break;
}
}
}