我想在活动中加入微调器。我已经完成了编码,并且向我显示了一个错误,即类职业必须是抽象方法或实现方法 “ onItemSelectedListener”。但是我已经实现了它们,并检查了所有现有情况是否存在此错误。香港专业教育学院甚至把代码放在onCreate()下。我的活动代码发布在下面
请帮帮我。任何帮助将不胜感激!
package com.appindia.srikavyanalluri.appindia;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
class Profession extends AppCompatActivity implements
AdapterView.OnItemSelectedListener
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profession);
Button clank = (Button) findViewById(R.id.prof);
final Intent a = getIntent();
String[] listName = {"<20,000", "20,000 - 30,000", "30,000 - 40,000", ">40,000"};
Spinner salary = (Spinner) findViewById(R.id.spin);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, listName);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
salary.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
Toast.makeText(Profession.this, "Please Select your Salary Range", Toast.LENGTH_SHORT).show();
}
}
);
clank.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EditText company = (EditText) findViewById(R.id.edit5);
EditText experience = (EditText) findViewById(R.id.edit6);
EditText designation = (EditText) findViewById(R.id.edit8);
Spinner salary = (Spinner) findViewById(R.id.spin);
String item = salary.getSelectedItem().toString();
if (company.getText().toString().isEmpty()) {
company.setError("Company Name is required!");
} else if (experience.getText().toString().isEmpty()) {
experience.setError("Years of experience is required!");
} else if (designation.getText().toString().isEmpty()) {
designation.setError("Your Job designation is required!");
} else {
Intent i = new Intent(Profession.this, Addresses.class);
i.putExtra("comp", company.getText().toString());
i.putExtra("exp", experience.getText().toString());
i.putExtra("item", item);
i.putExtra("desi", designation.getText().toString());
i.putExtra("Name", a.getStringExtra("Name"));
i.putExtra("father", a.getStringExtra("father"));
i.putExtra("gender", a.getStringExtra("gender"));
i.putExtra("home", a.getStringExtra("home"));
startActivity(i);
}
}
}
);
}
}