Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8413423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:55:15+00:00 2026-06-10T00:55:15+00:00

I am building an app that will search an array for two or more

  • 0

I am building an app that will search an array for two or more strings and return some information related to both strings. I need to access my variable entitled title in my OnClick. Here my code:

package com.rottenapi.applogictest;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray; 

import org.json.JSONObject;

import android.os.Bundle;
 import android.app.Activity;
import android.util.Log;
 import android.view.Menu;

import android.widget.EditText;
import android.widget.Button;
import android.view.View;

public class Main extends Activity {

private static String url = "http://api.rottentomatoes.com/api/public/v1.0/movies/770672123/cast.json?apikey=3p9ehnhzbxwpbd6mk8fncf67";
private static String TAG_CAST = "cast";
private static String TAG_LINKS = "links";
private static String TAG_NAME = "name";

public static String TAG_REL = "rel";
private static String TAG_TITLE = "Title";

EditText enterName;
EditText enterNameTwo;
EditText result;


Button findMovie;

String searchOne;
String searchTwo;
public String title;

List<String> castMembers = new ArrayList<String>();

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.mainlayout);



    JSONArray cast = null;

    JSONArray rel = null;

    JSONArray links = null;



    final JSONParser jParser = new JSONParser();

    final JSONObject jSon = jParser.getJSONFromUrl(url);



    enterName = (EditText) findViewById(R.id.enterName);
    enterNameTwo = (EditText) findViewById(R.id.enterNameTwo);
    result = (EditText) findViewById(R.id.result);

    searchOne = enterName.getText().toString();
    searchTwo = enterNameTwo.getText().toString();

    try{
        cast = jSon.getJSONArray(TAG_CAST);

        for(int i=0; i < cast.length(); i++){
            JSONObject c = cast.getJSONObject(i);

            String name = c.getString(TAG_NAME);

            castMembers.add(name);
        }

        if (castMembers.contains(searchOne) && castMembers.contains(searchTwo)){
            links = jSon.getJSONArray(TAG_LINKS);
            for(int i=0; i < links.length(); i++){
                JSONObject d = links.getJSONObject(i);

                String movieInfoLink = d.getString(TAG_REL);

                JSONObject jSonMovie = jParser.getJSONFromUrl(movieInfoLink);

                rel = jSonMovie.getJSONArray(TAG_REL);





            }for(int i =0; i < rel.length(); i++){

                JSONObject e = rel.getJSONObject(i);

                title = e.getString(TAG_TITLE);




            }
            findMovie.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    Log.d("Result contents", title);
                    result.setText(title);
                }
            });


        }

        }
        catch(Exception e){
            Log.e("Error", e.toString());
        }


}






@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.mainlayout, menu);
    return true;
}

When I run this the app displays in the emulator however after clicking the button nothing happens also no errors print in the logcat. My results contents log doesnt print out either in the log. Any ideas whats going on?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:55:16+00:00Added an answer on June 10, 2026 at 12:55 am

    This is because you haven’t linked your Button findMovie to the layout id for the Button. All you need to do is simply add the following line to your code and it will work:

    findMovie = (Button) findViewById(R.id.findMovieButton);
    

    Hope this helps..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building an iPhone app that will need to display info primarily in
i'm building an app that will display some newsletters to the users. the newsletters
This is the case I am building app that will be localized via strings
I'm building an app that will deal with very large files 100mb->1gb both upload
I'm building an app that will store some of our clients details, things like
I'm building an app that will grab a content from some CMS, and save
I'm building a little web app that will ping an array of domains and
I am building an MVC3 app that will require sending a mass email from
I am building a ASP.NET MVC App that will allow a user to connect
I'm building a login system within my app that will be called several times.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.