2017-01-14 11 views
1

私はアンドロイドが新しく、私はリサイクルビューでGoogleプレイスのオートコンプリートを使用するアプリを開発しています。私はアプリを実行しようとすると が、それは作業と示していないアプリケーションが動作しなくなりました: 'android.graphics.drawable.RippleDrawable'クラスが見つかりませんでした

クラスのandroid.graphics.drawable.RippleDrawable '、方法 から参照 が見つかりませんでしたandroid.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering

これに関連する質問がありますが、いずれも問題を解決しません。

はここ

<?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私activity_search_bus.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> 

SearchBus.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(); 
    } 
} 

感謝。

+0

どのラインでクラッシュしますか? –

+0

my_Recycle_destination.setLayoutManager(my_Layout_Manager)でクラッシュすると思います。 search_bus.javaファイル – Pegasus

+0

両方のビューで同じLayoutManagerを使用することはできません。 –

答えて

2

2つの異なるRecyclerViewに同じLayoutManagerを使用することはできません。各インスタンスごとに新しいインスタンスを作成し、別々に使用します。

+0

それは働いた。ありがとう。 – Pegasus

関連する問題