I will briefly write what I exactly want and where I'm exactly stucked.I'm loading a list in recycleview from api using retrofit(which I have loaded successfully)see this image-->image description here.
Further I have two api ids(example :https//..id=1 and https//..id=2 and so on depending upon this list image description here.)
here is my 2 apis:(first one https//..id=1)
{"id":"1","title":"Android Introduction","description":"
Android is a Linux based operating system it is designed primarily for touch screen mobile devices such as smart phones and tablet computers. The operating system have developed a lot in last 15 years starting from black and white phones to recent smart phones or mini computers. One of the most widely used mobile OS these days is android. The android is software that was founded in Palo Alto of California in 2003.<\/p>\r\n\r\n
\"\"<\/p>\r\n\r\n
The android is a powerful operating system and it supports large number of applications in Smartphones. These applications are more comfortable and advanced for the users. The hardware that supports android software is based on ARM architecture platform. The android is an open source operating system means that it’s free and any one can use it. The android has got millions of apps available that can help you managing your life one or other way and it is available low cost in market at that reasons android is very popular.<\/p>\r\n\r\n
\"\"<\/p>\r\n\r\n
The android development supports with the full java programming language. Even other packages that are API and JSE are not supported. The first version 1.0 of android development kit (SDK) was released in 2008 and latest updated version is jelly bean.<\/p>\r\n"}
second one:(https//..id=2)
{"id":"2","title":"Android Studio","description":"
Meet Android Studio<\/p>\r\n\r\n
Android Studio is the official Integrated Development Environment (IDE) for Android app development, based onIntelliJ IDEA <\/a>. On top of IntelliJ's powerful code editor and developer tools, Android Studio offers even more features that enhance your productivity when building Android apps, such as:<\/p>\r\n\r\n
\r\n\t
A flexible Gradle-based build system<\/li>\r\n\t
A fast and feature-rich emulator<\/li>\r\n\t
A unified environment where you can develop for all Android devices<\/li>\r\n\t
Apply Changes to push code and resource changes to your running app without restarting your app<\/li>\r\n\t
Code templates and GitHub integration to help you build common app features and import sample code<\/li>\r\n\t
Extensive testing tools and frameworks<\/li>\r\n\t
Lint tools to catch performance, usability, version compatibility, and other problems<\/li>\r\n\t
C++ and NDK support<\/li>\r\n\t
Built-in support for Google Cloud Platform<\/a>, making it easy to integrate Google Cloud Messaging and App Engine<\/li>\r\n<\/ul>\r\n\r\n
This page provides an introduction to basic Android Studio features. For a summary of the latest changes, seeAndroid Studio release notes<\/a>.<\/p>\r\n"}
As you can see from apis that on click on items should load their respective description from apis to next activity like this-->image description here
if you want I can share code.just tell what exactly you need .I will edit
here is my code for nextactivity adapter:
public class NextAndroidAdapter extends RecyclerView.Adapter<NextAndroidAdapter.CustomViewHolder> {
DescriptionModel WAmdel;
Context context;
public NextAndroidAdapter(Context context,DescriptionModel employees) {
this.WAmdel = employees;
this.context=context;
}
@Override
public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.nextwhatsandroid_item , parent, false);
return new CustomViewHolder(itemView);
}
@Override
public void onBindViewHolder(CustomViewHolder holder, final int position) {
// holder.textView.setText(String.valueOf(position+1)+". ");
holder.textView.setText(WAmdel.getDescription());
}
@Override
public int getItemCount() {
return 1;
}
public class CustomViewHolder extends RecyclerView.ViewHolder {
TextView textView;
public CustomViewHolder(View view) {
super(view);
// employeeName = (TextView) view.findViewById(R.id.WA2);
textView=view.findViewById(R.id.detailswhatsandroid);
}
});
}
}
}
this is my recycle view items adapter(of image description here):
public class WhatsAndroidAdapter extends RecyclerView.Adapter<WhatsAndroidAdapter.CustomViewHolder> {
List<WhatsAndroid.WhatsAndroidModel> WAmdel;
Context context;
public WhatsAndroidAdapter(Context context,List<WhatsAndroid.WhatsAndroidModel> employees) {
this.WAmdel = employees;
this.context=context;
}
@Override
public CustomViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.whatsandroid_item , parent, false);
return new CustomViewHolder(itemView);
}
@Override
public void onBindViewHolder(CustomViewHolder holder, final int position) {
holder.textView.setText(String.valueOf(position+1)+". ");
holder.employeeName.setText(WAmdel.get(position).getTitle());
}
@Override
public int getItemCount() {
return WAmdel.size();
}
public class CustomViewHolder extends RecyclerView.ViewHolder {
public TextView employeeName;
TextView textView;
public CustomViewHolder(View view) {
super(view);
employeeName = (TextView) view.findViewById(R.id.WA2);
textView=view.findViewById(R.id.WA1);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, NextActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra("title", WAmdel.get(getAdapterPosition()).getTitle());
context.startActivity(intent);
}
});
}
}
}
next activity:
public class NextActivity extends AppCompatActivity {
private RecyclerView recyclerView;
private NextAndroidAdapter adapter;
private DescriptionModel DescriptList;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.nextwhatsandroid_layout);
Toolbar toolbar = (Toolbar) findViewById(R.id. toolbar );
setSupportActionBar( toolbar );
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
Intent intent = getIntent();
String title = intent.getStringExtra("title");
String hello=intent.getStringExtra("hii");
getSupportActionBar().setTitle(title);
/*Create handle for the RetrofitInstance interface*/
DescriptService service = DescriptClientInstance.getRetrofitInstance().create(DescriptService.class);
Call<DescriptionModel> call = service.getAllPhotos();
call.enqueue(new Callback<DescriptionModel>() {
@Override
public void onResponse(Call<DescriptionModel> call, Response<DescriptionModel> response) {
// progressDialog.dismiss();
DescriptList=response.body();
generateDataList(DescriptList);
}
@Override
public void onFailure(Call<DescriptionModel> call, Throwable t) {
// progressDialog.dismiss();
Toast.makeText(getApplicationContext(), "Something went wrong...Please try later!", Toast.LENGTH_SHORT).show();
}
});
}
private void generateDataList(DescriptionModel photoList) {
recyclerView = findViewById(R.id.recyclenext);
LinearLayoutManager manager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(manager);
recyclerView.setHasFixedSize(true);
adapter = new NextAndroidAdapter(getApplicationContext(),photoList);
recyclerView.setAdapter(adapter);
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() ==android.R.id.home) {
finish();
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
super.onBackPressed();
}
}
but now im getting out as something like this: when I click on item0 it went to next screen and displays description of item1 but when I click on item1 it went to next screen displays same description as previous..what should I do in interface method of retrofit?
need help...thanks in advance