gpt4 book ai didi

java - 应用程序停止工作 : Could not find class 'android.graphics.drawable.RippleDrawable'

转载 作者:行者123 更新时间:2023-11-29 19:24:39 25 4
gpt4 key购买 nike

我是 android 的新手,我开发了一个应用程序,它使用谷歌放置自动完成和回收 View 。当我尝试运行该应用程序时,它无法正常工作并显示

Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering

有与此相关的问题,但都没有解决我的问题。

这是我的 activity_search_bus.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.busgeni.busgeni.SearchBus">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:gravity="center_horizontal"
android:orientation="vertical">

<EditText
android:id="@+id/idsource_txt"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_margin="50dp"
android:background="@drawable/write_text"
android:drawableLeft="@drawable/ic_search_black_24dp"
android:drawablePadding="10dp"
android:hint="@string/source_point"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
android:textColorHint="#c6c6c6" />

<EditText
android:id="@+id/iddestination_txt"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_margin="0dp"
android:background="@drawable/write_text"
android:drawableLeft="@drawable/ic_search_black_24dp"
android:drawablePadding="10dp"
android:hint="@string/destination_point"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
android:textColorHint="#c6c6c6" />


<Button
android:id="@+id/searchbutton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="60dp"
android:background="#1A237E"
android:padding="10dp"
android:text="@string/search_button"
android:textColor="#FFFFFF"
android:textSize="25sp" />

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView_source"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_below="@+id/idsource_txt"
android:layout_marginTop="10dp"
android:scrollbars="vertical" />

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView_des"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_below="@+id/iddestination_txt"
android:layout_marginTop="10dp"
android:scrollbars="vertical" />

</LinearLayout>

</RelativeLayout>

search_row.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="65dp"
android:id="@+id/idsearch_row"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_centerVertical="true"
android:background="@drawable/write_text"
android:gravity="center_horizontal">

<ImageView
android:id="@+id/locationimg"
android:layout_width="22dp"
android:layout_height="22dp"
android:src="@drawable/ic_location_on_black_18dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"/>

<TextView
android:id="@+id/location"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="22dp"
android:textColor="#000"
android:textSize="15sp"
android:layout_toRightOf="@+id/locationimg"
android:layout_marginBottom="20dp"
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp"/>

</RelativeLayout>

搜索总线.java

package com.example.busgeni.busgeni;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.busgeni.busgeni.Adapters.AT_Adapter;
import com.example.busgeni.busgeni.Listeners.Recycler_Listener;
import com.example.busgeni.busgeni.Utility.Constants;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.places.PlaceBuffer;
import com.google.android.gms.location.places.Places;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;

public class SearchBus extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, View.OnClickListener
{
GoogleApiClient my_client;

private static final LatLngBounds my_Bounds = new LatLngBounds(
new LatLng(-0, 0), new LatLng(0, 0));

private EditText my_source, my_destination;
private RecyclerView my_Recycle_source, my_Recycle_destination;
private LinearLayoutManager my_Layout_Manager;
private AT_Adapter my_AT_Adapter;

private static Button search_btn;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

buildGoogleApiClient();

setContentView(R.layout.activity_search_bus);

my_source = (EditText)findViewById(R.id.idsource_txt);
my_destination = (EditText)findViewById(R.id.iddestination_txt);

my_AT_Adapter = new AT_Adapter(this, R.layout.search_row,
my_client, my_Bounds, null);

my_Recycle_source=(RecyclerView)findViewById(R.id.recyclerView_source);
my_Recycle_destination=(RecyclerView)findViewById(R.id.recyclerView_des);
my_Layout_Manager=new LinearLayoutManager(this);

my_Recycle_source.setLayoutManager(my_Layout_Manager);
my_Recycle_source.setAdapter(my_AT_Adapter);
my_Recycle_destination.setLayoutManager(my_Layout_Manager);
my_Recycle_destination.setAdapter(my_AT_Adapter);

// delete.setOnClickListener(this);

my_source.addTextChangedListener(new TextWatcher()
{
public void onTextChanged(CharSequence s, int start, int before, int count)
{
if (!s.toString().equals("") && my_client.isConnected())
{
my_AT_Adapter.getFilter().filter(s.toString());
} else if(!my_client.isConnected())
{
Toast.makeText(getApplicationContext(), Constants.API_NOT_CONNECTED,Toast.LENGTH_SHORT).show();
Log.e(Constants.PlacesTag,Constants.API_NOT_CONNECTED);
}

}

public void beforeTextChanged(CharSequence s, int start, int count,
int after) {

}

public void afterTextChanged(Editable s) {

}
});

my_destination.addTextChangedListener(new TextWatcher()
{
public void onTextChanged(CharSequence s, int start, int before, int count)
{
if (!s.toString().equals("") && my_client.isConnected())
{
my_AT_Adapter.getFilter().filter(s.toString());
} else if(!my_client.isConnected())
{
Toast.makeText(getApplicationContext(), Constants.API_NOT_CONNECTED,Toast.LENGTH_SHORT).show();
Log.e(Constants.PlacesTag,Constants.API_NOT_CONNECTED);
}

}

public void beforeTextChanged(CharSequence s, int start, int count,
int after) {

}

public void afterTextChanged(Editable s) {

}
});

my_Recycle_source.addOnItemTouchListener( new Recycler_Listener(this, new Recycler_Listener.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
final AT_Adapter.PlaceAutocomplete item = my_AT_Adapter.getItem(position);
final String placeId = String.valueOf(item.placeId);
Log.i("TAG", "Autocomplete item selected: " + item.description);
/*
Issue a request to the Places Geo Data API to retrieve a Place object with additional details about the place.
*/

PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
.getPlaceById(my_client, placeId);
placeResult.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(PlaceBuffer places) {
if(places.getCount()==1){
//Do the things here on Click.....
Toast.makeText(getApplicationContext(),String.valueOf(places.get(0).getLatLng()),Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(getApplicationContext(),Constants.SOMETHING_WENT_WRONG,Toast.LENGTH_SHORT).show();
}
}
});
Log.i("TAG", "Clicked: " + item.description);
Log.i("TAG", "Called getPlaceById to get Place details for " + item.placeId);
}
})
);

my_Recycle_destination.addOnItemTouchListener( new Recycler_Listener(this, new Recycler_Listener.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
final AT_Adapter.PlaceAutocomplete item = my_AT_Adapter.getItem(position);
final String placeId = String.valueOf(item.placeId);
Log.i("TAG", "Autocomplete item selected: " + item.description);
/*
Issue a request to the Places Geo Data API to retrieve a Place object with additional details about the place.
*/

PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
.getPlaceById(my_client, placeId);
placeResult.setResultCallback(new ResultCallback<PlaceBuffer>() {
@Override
public void onResult(PlaceBuffer places) {
if(places.getCount()==1){
//Do the things here on Click.....
Toast.makeText(getApplicationContext(),String.valueOf(places.get(0).getLatLng()),Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(getApplicationContext(),Constants.SOMETHING_WENT_WRONG,Toast.LENGTH_SHORT).show();
}
}
});
Log.i("TAG", "Clicked: " + item.description);
Log.i("TAG", "Called getPlaceById to get Place details for " + item.placeId);
}
})
);

onClickButtonListener();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
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();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}*/

public void onClickButtonListener() {
search_btn = (Button) findViewById(R.id.searchbutton);
search_btn.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent("com.example.busgeni.busgeni.SearchResult");
startActivity(intent);
}
}
);
}

@Override
public void onStart() {
super.onStart();

}

@Override
public void onStop() {
super.onStop();

}

@Override
public void onResume()
{
super.onResume();
if (!my_client.isConnected() && !my_client.isConnecting()){
Log.v("Google API","Connecting");
my_client.connect();
}
}

@Override
public void onPause() {
super.onPause();
if(my_client.isConnected()){
Log.v("Google API","Dis-Connecting");
my_client.disconnect();
}
}

@Override
public void onBackPressed() {
super.onBackPressed();
}

@Override
public void onConnected(@Nullable Bundle bundle) {
Log.v("Google API Callback", "Connection Done");
}

@Override
public void onConnectionSuspended(int i) {
Log.v("Google API Callback", "Connection Suspended");
Log.v("Code", String.valueOf(i));
}

@Override
public void onClick(View v) {
/*if(v==delete){
my_source.setText("");
}*/
}

@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Log.v("Google API Callback","Connection Failed");
Log.v("Error Code", String.valueOf(connectionResult.getErrorCode()));
Toast.makeText(this, Constants.API_NOT_CONNECTED,Toast.LENGTH_SHORT).show();
}

protected synchronized void buildGoogleApiClient() {
my_client = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.addApi(Places.GEO_DATA_API)
.build();
}
}

提前致谢。

最佳答案

您不能对两个不同的 RecyclerView 使用相同的 LayoutManager。为每个创建一个新实例,并分别使用它们。

关于java - 应用程序停止工作 : Could not find class 'android.graphics.drawable.RippleDrawable' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41648586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com