Click here to Skip to main content
15,881,742 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
public class MoviesActivity extends Activity
{
 ListView lv;
 ArrayList<String> names,links;
 ArrayAdapter<String> adapter;
 String json="";

 @Override
 protected void onCreate(Bundle savedInstanceState)
 {
 super.onCreate(savedInstanceState);
setContentView(R.layout.main);
 setTitle(getIntent().getStringExtra("group"));

 lv = findViewById(R.id.lv);

 lv.setOnItemClickListener(new OnItemClickListener(){

 @Override
 public void onItemClick(AdapterView<?> p1, View p2, int p3, long p4)
 {
 Intent intent=new Intent(MoviesActivity.this, ViewerActivity.class);
 intent.putExtra("link", links.get(p3));
 startActivity(intent);
 }
 });

 json = getIntent().getStringExtra("json");
 processJSON(json);
 }

 private void processJSON(String input)
 {

 names = new ArrayList<>();
 links = new ArrayList<>();
 try
 {
 JSONObject jo=new JSONObject(Html.fromHtml(input).toString());
 JSONArray ja=jo.getJSONArray("movies");
 JSONObject jo2;
 for (int i=0;i < ja.length();i++)
 {
 jo2 = ja.getJSONObject(i);
 names.add(jo2.getString("title"));
 links.add(jo2.getString("link"));
 }
 adapter = new ArrayAdapter<String>(MoviesActivity.this, android.R.layout.simple_list_item_1, names);
 lv.setAdapter(adapter);
 }
 catch (JSONException e)
 {
 Toast.makeText(this, e.toString(), 1).show();
 }
 }
}


What I have tried:

I can't add recycler view ,card view and search function and swipe refresh layout.Help me please.
Posted
Updated 14-Sep-20 3:55am
v2
Comments
David Crow 14-Sep-20 14:34pm    
Do you have a RecyclerView widget on the main layout? Have you implemented the onCreateOptionsMenu() and onOptionsItemSelected() methods? For the last item, you need to study up on the SwipeRefreshLayout class.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900