Java 无法解析构造函数
我有一个错误,我不知道为什么在我的银河王牌三星(安卓2.3.6)不工作,但在我的摩托罗拉G(安卓4.4)工作完美。异常非常奇怪这是我的代码:Java 无法解析构造函数,java,android,android-studio,Java,Android,Android Studio,我有一个错误,我不知道为什么在我的银河王牌三星(安卓2.3.6)不工作,但在我的摩托罗拉G(安卓4.4)工作完美。异常非常奇怪这是我的代码: adapter = new SimpleCursorAdapter(this,R.layout.single_row_profession, cursor,from,to,0); package com.orun.app; import android.app.Activity; import android.content.Context; impo
adapter = new SimpleCursorAdapter(this,R.layout.single_row_profession, cursor,from,to,0);
package com.orun.app;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.orun.database.DataBaseManager;
import com.orun.model.Profession;
import com.orun.s.SConnection;
public class ProfessionsActivity extends Activity {
public static SConnection sConnection;
public static DataBaseManager manager;
private static Cursor cursor;
private static ListView listView;
private static SimpleCursorAdapter adapter;
private static EditText etSearch;
private static ImageButton btSearch;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_professions);
SharedPreferences sharedPref = getSharedPreferences(getString(R.string.PREFERENCE_FILE_KEY), Context.MODE_PRIVATE);
Toast.makeText(getApplicationContext(), "Rol "+sharedPref.getString("ROL","Estudiante"),Toast.LENGTH_LONG).show();
manager = new DataBaseManager(this);
listView = (ListView) findViewById(R.id.listView);
etSearch = (EditText)findViewById(R.id.etSearch);
new LoadTask().execute();
cursor = manager.searchProfession(etSearch.getText().toString());
int[] to = new int[]{R.id.textCode, R.id.textName,R.id.textType};
String[] from = new String[]{"_id","name","type"};
try {
adapter = new SimpleCursorAdapter(this,R.layout.single_row_profession, cursor,from,to,0);
}catch (Exception e){
e.printStackTrace();
}
listView.setAdapter(adapter);
etSearch.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
new SearchTask().execute();
adapter.changeCursor(cursor);
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {}
public void onTextChanged(CharSequence s, int start, int before,
int count) {}
});
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(ProfessionsActivity.this,PrincipalActivity.class);
int codeProfession = Integer.parseInt(((TextView)(view.findViewById(R.id.textCode))).getText().toString());
SharedPreferences sharedPref = getSharedPreferences(getString(R.string.PREFERENCE_FILE_KEY), Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putInt("CODE_PROFESSION", codeProfession);
editor.commit();
startActivity(intent);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.professions, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
private class SearchTask extends AsyncTask<Void, Void, Void>{
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... params) {
cursor = manager.searchProfession(etSearch.getText().toString());
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
}
}
private class LoadTask extends AsyncTask<Void, Void, Void>{
@Override
protected Void doInBackground(Void... params) {
try {
sConnection = new SConnection();
for(Profession p : sConnection.getPlansPreg())
manager.insertProfession(p.getCode(),p.getName(),"PRE");
for(Profession p : sConnection.getPlansPos())
manager.insertProfession(p.getCode(),p.getName(),"POS");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
Toast.makeText(getApplicationContext(),"Se han cargador todos los planes",Toast.LENGTH_SHORT).show();
}
}
您正在使用的构造函数是在API级别11中添加的,所以它在Android 2.3.6(API级别10)中不存在也就不足为奇了 公共SimpleCursorAdapter(上下文上下文、int布局、游标c、, API级别11中添加的字符串[]from,int[]to,int标志) 标准构造函数 参数 上下文上下文 与此SimpleListItemFactory关联的ListView正在运行 布局定义此列表项视图的布局文件的资源标识符。布局文件应至少包括“到”中定义的命名视图 c数据库光标。如果光标尚不可用,则可以为null 来自表示要绑定到UI的数据的列名列表。如果光标尚不可用,则可以为null 到应在“from”参数中显示列的视图。这些都应该是文本视图。此列表中的前N个视图提供了from参数中前N列的值。如果光标尚不可用,则可以为null 标志根据游标适配器(上下文、游标、int)确定适配器行为的标志
请参阅。哪个类的构造函数?看起来这个类的api在Android 2.3.6和Android 4.4之间发生了变化
'(Landroid/context/Context;ILandroid/database/Cursor;[Ljava/lang/String;[II)V