0

Please help me. Am using Eclipse ADT for development. I am facing a problem and i am not able to fix. I tried lots of answers in this stackoverflow but no one give a right solution. Let me explain my problem

  1. I imported recyclerview project from this path

E:\software\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\extras\android\support\v7\recyclerview

  1. After imported, right click on recyclerview project--> properties --> android tab (From left pane) ---> make checked isLibrary checkbox

  2. Then causally, i write a code in my class which extends the fragment

public class FragmentTab1 extends Fragment {

View view;

RecyclerView mRecyclerView;

TimelineAdapter timelineAdapter;

// ListView listView;
// RecyclerView mRecyclerView;
// RecyclerView.LayoutManager mLayoutManager;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    // Get the view from fragmenttab1.xml
    try {
        view = inflater.inflate(R.layout.fragmenttab1, container, false);

        mRecyclerView = (RecyclerView) view
                .findViewById(R.id.my_recycler_view);

        mRecyclerView.setHasFixedSize(false);
        mRecyclerView.setAdapter(new TimelineAdapter(getActivity()));
    } catch (Exception e) {
        // TODO: handle exception
        Log.e("FragOne error ", "" + e.getMessage());
        Log.e("FragOne error ", "" + e.getCause());
    }

    return view;
}

}

I have written adapter class and am 100% sure there is no errors.

When i am seeing the layout xml file then i am unble to see the recyclerview. Please refer the image attchment below

enter image description here

Please take a look about my xml file what i have written

<FrameLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/light_grey"
tools:context=".LoginFollowUsers" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <android.support.v7.widget.RecyclerView
        android:id="@+id/my_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/letterimg"
        android:scrollbars="vertical" />
</LinearLayout>

After i am importing recyclerview project from support/v7/recyclerview i am not able to see any file in src folder.. can any one share the recyclerview project

Please help me out form this issue

Thanks in advance to all

user1784588
  • 99
  • 2
  • 12
  • when you run it what happens ? – Vishal Makasana Aug 18 '15 at 10:44
  • 2
    I guess you missed one step. Please make sure you have add recyclerView library into your project. – Bhavin Shah Aug 18 '15 at 10:47
  • in my code i kept the log for error. here the error am getting from the log 08-18 16:18:34.725: E/FragOne error(23243): Binary XML file line #16: Error inflating class android.support.v7.widget.RecyclerView 08-18 16:18:34.725: E/FragOne error(23243): java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.RecyclerView" on path: DexPathList[[zip file "/data/app/com.androidbegin.pagertabstriptutorial-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.androidbegin.pagertabstriptutorial-1, /vendor/lib, /system/lib]] – user1784588 Aug 18 '15 at 10:48
  • have you imported the **android-support-v7-recyclerview project** as library in your project? – Shadow Droid Aug 18 '15 at 10:54
  • Check this link: http://stackoverflow.com/questions/26492345/importing-cardview-and-recyclerview-android-5-0-in-my-existing-project-eclips Hope it will help! – challenger Aug 18 '15 at 10:57
  • did you add the support lib ? – Murtaza Khursheed Hussain Aug 18 '15 at 11:01
  • where you add items to the recycler view? – m.v.n.kalyani Aug 18 '15 at 11:13
  • Ya i have import recyclerview from support/v7/recyclerview project.. i make it as a library and added with my project, but still my xml file showing The following classes could not be instantiated: - android.support.v7.widget.RecyclerView (Open Class, Show Error Log) – user1784588 Aug 18 '15 at 12:01
  • i am adding my items in adpter class.. that adapter class contains cardview and no probs on that.. When am seeing in xml file, the cardview is displaying but, when i try to see recyclerview in xml file, its not showing and am seeing error still now.. how i can fix it ?? will u pls tell me – user1784588 Aug 18 '15 at 12:11

4 Answers4

0

You have to explicitly set LayoutManager for RecyclerView:

mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity));

Without this RecyclerView will no run.

skrzatswat
  • 59
  • 5
0

You need JDK 8 for new android library set JDK and JRE and try it will work.!!!!

i had same issue but after installing JDK 8 it's resolved

Kishore Jethava
  • 6,666
  • 5
  • 35
  • 51
0

You should add recylerView library into your project. Right click on your project in your project explorer > Select properties > navigate to android in left pane > now click on ADD button in right pane > After clicking add button you should add recylerView library.

You need to add following code in your java file while defining recylerView.

mRecyclerView = (RecyclerView) view
            .findViewById(R.id.my_recycler_view);
mRecyclerView.setLayoutManager(new LinearLayoutManager(
                getActivity()));
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
Bhavin Shah
  • 361
  • 4
  • 11
0

You need to add card view to show the recycler view items.I am sending sample code.try it once.

Import cardview project from this path

E:\software\adt-bundle-windows-x86_64-20140702\adt-bundle-windows-x86_64-20140702\sdk\extras\android\support\v7\cardview

In your Frgment class:

RecyclerView recList = (RecyclerView) view.findViewById(R.id.cardList);
        recList.setHasFixedSize(true);
        LinearLayoutManager llm = new LinearLayoutManager(getActivity());
        llm.setOrientation(LinearLayoutManager.VERTICAL);
        recList.setLayoutManager(llm);

        ArrayList<MyBean> myListItems = new ArrayList<MyBean>();
        for (int i = 0; i < 5; i++) {

            myListItems.add(new MyBean("item:"+i));
        }

        MyRecycleAdapter  adapter = new MyRecycleAdapter(myListItems);
        recList.setAdapter(adapter);

MyAdapter.class

public class MyRecycleAdapter extends RecyclerView.Adapter {

private List<MyBean> myItemsList;

public MyRecycleAdapter  (List<MyBean> myItemsList) {
    this.myItemsList = myItemsList;
}

@Override
public int getItemCount() {
    return myItemsList.size();
}

@Override
public void onBindViewHolder(MyViewHolder viewHolder, int i) {

    MyBean ci = myItemsList.get(i);
    MyViewHolder.id.setText("" + ci.getId());


}

@Override
public MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
    View itemView = LayoutInflater.from(viewGroup.getContext()).inflate(
            R.layout.mycardview, viewGroup, false);

    return new MyViewHolder(itemView);
}

public static class MyViewHolder extends RecyclerView.ViewHolder {

    protected TextView id;

    public MyViewHolder(View v) {
        super(v);
        id = (TextView) v.findViewById(R.id.textView1);

    }
}

}

and in your mycardview.xml

just take one textview.

m.v.n.kalyani
  • 760
  • 7
  • 20
  • Sorry friend again am getting this error 08-18 17:30:10.651: E/FragOne error(2569): Binary XML file line #16: Error inflating class android.support.v7.widget.RecyclerView 08-18 17:30:10.651: E/FragOne error(2569): java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.RecyclerView" on path: DexPathList[[zip file "/data/app/com.androidbegin.pagertabstriptutorial-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.androidbegin.pagertabstriptutorial-1, /vendor/lib, /system/lib]] – user1784588 Aug 18 '15 at 11:59
  • can u please check your support libs are updated to latest.. com.android.support:support-v4: and com.android.support:recyclerview-v7 – m.v.n.kalyani Aug 18 '15 at 13:43