これは私のJavaクラスとこのコードです。私はリストビューとしてstickylistheaderViewを使いたい。必須のSDK例外android 'se.emilsjolander.stickylistheaders.StickyListHeadersListView'
public class UsersList extends AppCompatActivity implements View.OnClickListener {
LinearLayout llTab2;
RelativeLayout llTab1;
SeekBar sbDistance;
TextView tvProgress;
Utils utils;
ArrayList<String> name;
StickyListHeadersListView stickyList;
Map<String, Integer> mapIndex;
private MapView myOpenMapView;
private MapController myMapController;
LocationManager locationManager;
ArrayList<OverlayItem> overlayItemArray;
DefaultResourceProxyImpl defaultResourceProxyImpl;
DatabaseHelper dbhelper;
ConnectionDetector cd;
Button main_cerca_tabler, main_tablers_vicini_a_te;
// LinearLayout edittextView;
EditText surnameEdt, tavolaEdt, cityEdt, regionEdt, professionEdt;
ArrayList<UserDetails> offlineDetails;
ArrayList<UserDetails> offlineDetailsSearch;
private ArrayList<OverlayItem> OverlayItemArray;
public Location curlocation;
public GPSTracker gpsTracker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search_userlist);
ActionBar actinBar = getSupportActionBar();
actinBar.setDisplayHomeAsUpEnabled(true);
actinBar.setHomeAsUpIndicator(R.drawable.white_back_arrow);
actinBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(UsersList.this, R.color.actionbarblue)));
main_cerca_tabler = (Button) findViewById(R.id.main_cerca_tabler);
main_tablers_vicini_a_te = (Button) findViewById(R.id.main_tablers_vicini_a_te);
// edittextView = (LinearLayout) findViewById(R.id.edittextView);
stickyList = (StickyListHeadersListView) findViewById(R.id.list);
surnameEdt = (EditText) findViewById(R.id.header_list_surname_edt);
myOpenMapView = (MapView) findViewById(R.id.openmapview);
tavolaEdt = (EditText) findViewById(R.id.header_list_tovelo_edt);
cityEdt = (EditText) findViewById(R.id.header_list_city_edt);
regionEdt = (EditText) findViewById(R.id.header_list_region_edt);
professionEdt = (EditText) findViewById(R.id.header_list_profession_edt);
llTab1 = (RelativeLayout) findViewById(R.id.llTab1_HeaderList);
llTab2 = (LinearLayout) findViewById(R.id.llTab2_HeaderList);
sbDistance = (SeekBar) findViewById(R.id.sbDistance_HEADER_LIST);
sbDistance.setProgressDrawable(ContextCompat.getDrawable(UsersList.this, R.drawable.ic_seekbar_background));
sbDistance.setMax(50);
tvProgress = (TextView) findViewById(R.id.tvProgress_HeaderList);
sbDistance.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
tvProgress.setText("" + seekBar.getProgress());
}
});
utils = new Utils(UsersList.this);
dbhelper = new DatabaseHelper(UsersList.this);
cd = new ConnectionDetector(UsersList.this);
gpsTracker = new GPSTracker(this);
myOpenMapView.setBuiltInZoomControls(true);
myOpenMapView.setMultiTouchControls(true);
myOpenMapView.setClickable(true);
myMapController = (MapController) myOpenMapView.getController();
overlayItemArray = new ArrayList<OverlayItem>();
offlineDetailsSearch = new ArrayList<UserDetails>();
if (gpsTracker.canGetLocation()) {
try {
GeoPoint geoPoint = new GeoPoint(gpsTracker.getLatitude(), gpsTracker.getLongitude());
myMapController.setCenter(geoPoint);
} catch (Exception e) {
Toast.makeText(UsersList.this, "" + e.toString(), Toast.LENGTH_SHORT).show();
}
} else {
gpsTracker.showSettingsAlert();
}
main_cerca_tabler.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
llTab2.setVisibility(View.VISIBLE);
llTab1.setVisibility(View.GONE);
main_cerca_tabler.setBackground(ContextCompat.getDrawable(UsersList.this, R.drawable.corner_yellow));
main_tablers_vicini_a_te.setBackgroundResource(0);
Drawable img = ContextCompat.getDrawable(UsersList.this, R.drawable.ic_white_user);
main_cerca_tabler.setCompoundDrawablesWithIntrinsicBounds(img, null, null, null);
Drawable img1 = ContextCompat.getDrawable(UsersList.this, R.drawable.ic_blue_location);
main_tablers_vicini_a_te.setCompoundDrawablesWithIntrinsicBounds(img1, null, null, null);
main_cerca_tabler.setTextColor(ContextCompat.getColor(UsersList.this, R.color.white));
main_tablers_vicini_a_te.setTextColor(ContextCompat.getColor(UsersList.this, R.color.blue));
}
});
main_tablers_vicini_a_te.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
llTab2.setVisibility(View.GONE);
llTab1.setVisibility(View.VISIBLE);
main_tablers_vicini_a_te.setBackground(ContextCompat.getDrawable(UsersList.this, R.drawable.corner_yellow));
main_cerca_tabler.setBackgroundResource(0);
Drawable img = ContextCompat.getDrawable(UsersList.this, R.drawable.ic_white_location);
main_tablers_vicini_a_te.setCompoundDrawablesWithIntrinsicBounds(img, null, null, null);
Drawable img1 = ContextCompat.getDrawable(UsersList.this, R.drawable.ic_blue_user);
main_cerca_tabler.setCompoundDrawablesWithIntrinsicBounds(img1, null, null, null);
main_cerca_tabler.setTextColor(ContextCompat.getColor(UsersList.this, R.color.blue));
main_tablers_vicini_a_te.setTextColor(ContextCompat.getColor(UsersList.this, R.color.white));
}
});
if (cd.isConnectingToInternet()) {
new getData().execute();
} else {
OverlayItemArray = new ArrayList<>();
setUpMap();
offlineDetails = dbhelper.getAllUser();
name = new ArrayList<String>();
for (int i = 0; i < offlineDetails.size(); i++) {
name.add(offlineDetails.get(i).getName());
OverlayItem object1 = new OverlayItem(
"", "", new GeoPoint(Double.parseDouble(offlineDetails.get(i).getLat()), Double.parseDouble(offlineDetails.get(i).getLog())));
Drawable newMarker = ContextCompat.getDrawable(UsersList.this, R.drawable.ic_marker);
object1.setMarker(newMarker);
OverlayItemArray.add(object1);
}
setUpList(name, offlineDetails);
putAllPin(OverlayItemArray);
}
}
private void searchProfession(String s) {
String surname = surnameEdt.getText().toString();
String tavola = tavolaEdt.getText().toString();
// String profession = professionEdt.getText().toString();
String city = cityEdt.getText().toString();
// String profession = professionEdt.getText().toString();
ArrayList<String> name = new ArrayList<>();
offlineDetailsSearch = new ArrayList<>();
for (int i = 0; i < offlineDetails.size(); i++) {
UserDetails details = offlineDetails.get(i);
if (details.getTavola().contains(tavola) && details.getSurname().contains(surname) && details.getCity().contains(city) && details.getProfession().contains(s)) {
offlineDetailsSearch.add(offlineDetails.get(i));
name.add(offlineDetails.get(i).getName());
}
}
setUpList(name, offlineDetailsSearch);
}
private void searchCity(String s) {
String surname = surnameEdt.getText().toString();
String tavola = tavolaEdt.getText().toString();
String profession = professionEdt.getText().toString();
// String city = cityEdt.getText().toString();
// String profession = professionEdt.getText().toString();
ArrayList<String> name = new ArrayList<>();
offlineDetailsSearch = new ArrayList<>();
for (int i = 0; i < offlineDetails.size(); i++) {
UserDetails details = offlineDetails.get(i);
if (details.getTavola().contains(tavola) && details.getSurname().contains(surname) && details.getCity().contains(s) && details.getProfession().contains(profession)) {
offlineDetailsSearch.add(offlineDetails.get(i));
name.add(offlineDetails.get(i).getName());
}
}
setUpList(name, offlineDetailsSearch);
}
private void searchTavola(String s) {
String surname = surnameEdt.getText().toString();
// String tavola = tavolaEdt.getText().toString();
String profession = professionEdt.getText().toString();
String city = cityEdt.getText().toString();
// String profession = professionEdt.getText().toString();
ArrayList<String> name = new ArrayList<>();
offlineDetailsSearch = new ArrayList<>();
for (int i = 0; i < offlineDetails.size(); i++) {
UserDetails details = offlineDetails.get(i);
if (details.getTavola().contains(s) && details.getSurname().contains(surname) && details.getCity().contains(city) && details.getProfession().contains(profession)) {
offlineDetailsSearch.add(offlineDetails.get(i));
name.add(offlineDetails.get(i).getName());
}
}
setUpList(name, offlineDetailsSearch);
}
private void searchSurname(String s) {
// String surname = surnameEdt.getText().toString();
String tavola = tavolaEdt.getText().toString();
String profession = professionEdt.getText().toString();
String city = cityEdt.getText().toString();
// String profession = professionEdt.getText().toString();
ArrayList<String> name = new ArrayList<>();
offlineDetailsSearch = new ArrayList<>();
for (int i = 0; i < offlineDetails.size(); i++) {
UserDetails details = offlineDetails.get(i);
if (details.getSurname().contains(s) && details.getTavola().contains(tavola) && details.getProfession().contains(profession) && details.getCity().contains(city)) {
offlineDetailsSearch.add(offlineDetails.get(i));
name.add(offlineDetails.get(i).getName());
}
}
setUpList(name, offlineDetailsSearch);
}
private void setUpMap() {
defaultResourceProxyImpl = new DefaultResourceProxyImpl(this);
// MyItemizedIconOverlay myItemizedIconOverlay = new MyItemizedIconOverlay(overlayItemArray, null, defaultResourceProxyImpl);
// myOpenMapView.getOverlays().add(myItemizedIconOverlay);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
//for demo, getLastKnownLocation from GPS only, not from NETWORK
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
Location lastLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
// Location lastLocation = new Location("");
// lastLocation.setLatitude(20.30);
// lastLocation.setLongitude(52.30);
// if (lastLocation != null) {
// updateLoc(lastLocation);
// }
//Add Scale Bar
// ScaleBarOverlay myScaleBarOverlay = new ScaleBarOverlay(this);
// myOpenMapView.getOverlays().add(myScaleBarOverlay);
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onPause() {
super.onPause();
}
private void displayIndex() {
LinearLayout indexLayout = (LinearLayout) findViewById(R.id.side_index);
TextView textView;
List<String> indexList = new ArrayList<String>(mapIndex.keySet());
for (String index : indexList) {
textView = (TextView) getLayoutInflater().inflate(
R.layout.side_index_item, null);
textView.setText(index);
textView.setOnClickListener(this);
if (indexLayout != null) {
indexLayout.addView(textView);
}
}
}
private void getIndexList(ArrayList<String> fruits) {
mapIndex = new LinkedHashMap<String, Integer>();
for (int i = 0; i < fruits.size(); i++) {
String fruit = fruits.get(i);
String index = fruit.substring(0, 1);
if (mapIndex.get(index) == null) {
mapIndex.put(index, i);
}
}
}
@Override
public void onClick(View view) {
TextView selectedIndex = (TextView) view;
stickyList.setSelection(mapIndex.get(selectedIndex.getText()));
}
private class getData extends AsyncTask<String, String, String> {
ProgressDialog pd;
@Override
protected void onPreExecute() {
super.onPreExecute();
name = new ArrayList<String>();
OverlayItemArray = new ArrayList<>();
pd = new ProgressDialog(UsersList.this);
pd.setMessage("Loading...");
pd.setCancelable(false);
pd.show();
overlayItemArray.clear();
}
@Override
protected String doInBackground(String... params) {
return utils.getResponseofGet(Constant.BASE_URL + "api_user.php");
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
pd.dismiss();
JSONObject issueObj = null;
setUpMap();
offlineDetails = new ArrayList<UserDetails>();
try {
issueObj = new JSONObject(s);
Iterator<String> iterator = issueObj.keys();
while (iterator.hasNext()) {
String key = iterator.next();
JSONArray mainArray = issueObj.getJSONArray(key);
for (int i = 0; i < mainArray.length(); i++) {
JSONObject object = mainArray.getJSONObject(i);
String id, social_class, areaid, zoneid,
clubid, nationalID, surname,
dob, tavola, city, profession, province,
tel_phone, name_wife, photo, inc_area,
Postal_Code, homephone, mobilephone, workphone, fax,
address_home, email, password, occupation, fb, lat, log,
twitter, linkedin, googleplus,
deviceid, status;
String Name = object.getString("name").substring(0, 1).toUpperCase() + object.getString("name").substring(1);
name.add(Name);
// Double latitude = Double.parseDouble(object.getString("lat"));
// Double longitude = Double.parseDouble(object.getString("log"));
//
// UserDetails details = new UserDetails();
// details.setName(Name);
// details.setId(object.getString("id"));
// details.setSurname(object.getString("surname"));
// details.setTavola(object.getString("tavola"));
// details.setCity(object.getString("city"));
// details.setProfession(object.getString("profession"));
photo = "http://www.roundtable.it/uploads/tx_annuario/" + object.getString("photo").toString();
social_class = object.getString("social_class").toString();
lat = object.getString("lat").toString();
log = object.getString("log").toString();
Double latitude = Double.parseDouble(object.getString("lat"));
Double longitude = Double.parseDouble(object.getString("log"));
UserDetails details = new UserDetails();
details.setName(Name);
details.setId(object.getString("id"));
details.setFb(fb);
details.setLat(lat);
details.setLog(log);
details.setTwitter(twitter);
details.setLinkedin(linkedin);
details.setGoogleplus(googleplus);
details.setDeviceid(deviceid);
details.setStatus(status);
offlineDetails.add(details);
if (latitude != 0.0) {
Location location = new Location("List");
Log.e("location", "" + location);
location.setLatitude(latitude);
location.setLongitude(longitude);
// float distance = location.distanceTo(curlocation);
// setOverlayLoc(location);
// GeoPoint startPoint = new GeoPoint(latitude, longitude);
// myMapController.setCenter(startPoint);
OverlayItem object1 = new OverlayItem(
"", "", new GeoPoint(latitude, longitude));
Drawable newMarker = ContextCompat.getDrawable(UsersList.this, R.drawable.ic_marker);
object1.setMarker(newMarker);
OverlayItemArray.add(object1);
}
}
}
} catch (JSONException e) {
e.printStackTrace();
}
putAllPin(OverlayItemArray);
dbhelper.insertUserList(offlineDetails);
setUpList(name, offlineDetails);
}
}
public void putAllPin(ArrayList<OverlayItem> array) {
myOpenMapView.getOverlays().clear();
ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay = new ItemizedIconOverlay<OverlayItem>(
UsersList.this, array, null);
myOpenMapView.getOverlays().add(anotherItemizedIconOverlay);
ScaleBarOverlay myScaleBarOverlay = new ScaleBarOverlay(UsersList.this);
myOpenMapView.getOverlays().add(myScaleBarOverlay);
}
public class SortBasedOnName implements Comparator {
public int compare(Object o1, Object o2) {
String dd1 = (String) o1;// where FBFriends_Obj is your object class
String dd2 = (String) o2;
return dd1.compareToIgnoreCase(dd2);//where uname is field name
}
}
public void setUpList(ArrayList<String> name, ArrayList<UserDetails> arrayUserDetails) {
Collections.sort(name, new SortBasedOnName());
Collections.sort(arrayUserDetails, new Comparator<UserDetails>() {
@Override
public int compare(UserDetails lhs, UserDetails rhs) {
return lhs.getName().compareToIgnoreCase(rhs.getName());
}
});
MyAdapter adapter = new MyAdapter(UsersList.this, arrayUserDetails);
stickyList.setAdapter(adapter);
stickyList.setOnTouchListener(new View.OnTouchListener() {
// Setting on Touch Listener for handling the touch inside ScrollView
@Override
public boolean onTouch(View v, MotionEvent event) {
// Disallow the touch request for parent scroll on touch of child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
// setListViewHeightBasedOnChildren(stickyList);
getIndexList(name);
displayIndex();
}
}
私はlogcatの下に取得しています。私はlogcatが私にクラスに必要な高sdkバージョンを教えていると思う。ここに私のLogcatは
E/dalvikvm: Could not find class 'se.emilsjolander.stickylistheaders.WrapperViewList', referenced from method se.emilsjolander.stickylistheaders.StickyListHeadersListView.
E/dalvikvm: Could not find class 'se.emilsjolander.stickylistheaders.ApiLevelTooLowException', referenced from method se.emilsjolander.stickylistheaders.StickyListHeadersListView.requireSdkVersion E/dalvikvm: Could not find class 'se.emilsjolander.stickylistheaders.StickyListHeadersListView$1', referenced from method se.emilsjolander.stickylistheaders.StickyListHeadersListView.swapHeader E/AndroidRuntime: FATAL EXCEPTION: main Process: com.app.archirayan.offline, PID: 31880 java.lang.VerifyError: se/emilsjolander/stickylistheaders/StickyListHeadersListView at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at android.view.LayoutInflater.createView(LayoutInflater.java:594) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) at com.app.archirayan.offline.Activity.UsersList.onCreate(UsersList.java:94) at android.app.Activity.performCreate(Activity.java:5239) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1099) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2230) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2336) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1230) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5299)
ここに私のgradleファイルです。 は、プラグインを適用する:「com.android.application」
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.app.archirayan.offline"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile files('libs/quickscroll-0.9.8.jar')
compile files('libs/slf4j-android-1.5.8.jar')
compile files('libs/osmdroid-android-3.0.3.jar')
compile files('libs/osmbonuspack_v3.7.jar')
compile 'com.android.support:appcompat-v7:24.0.0-beta1'
compile 'com.android.support:design:24.0.0-beta1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.sundeepk:compact-calendar-view:1.8.4'
compile 'se.emilsjolander:stickylistheaders:2.1.3'
}
だから、私を助けてください...私は正確に問題が何であるかを取得していないです。..事前にありがとうございます。
よう
MultiDexApplication
によって、アプリケーションクラスを拡張し、マニフェストに追加しますか – SripadRaj
最小APIレベルは19です..まだこの同じ問題が発生しています.. – Archi
あなたのgradleファイルを投稿してください – SripadRaj