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

  • Home
  • SEARCH
  • 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 7838783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:12:37+00:00 2026-06-02T15:12:37+00:00

I’m trying to make it so that once the user click on an item

  • 0

I’m trying to make it so that once the user click on an item in my listview, it goes to another class that has been dynamically created for the occasion. To add on, I’m creating a contact list App and when the user click on the App it shows Texts and call history that’s gone through our system; I’m not sure how to do this, I guess the Garbage collecter method work work well, although, I think it’s the wrong context.

Thanks 🙂

Code:

public class ChatService extends ListActivity {
  String GotPass;
  String GotUname;
  public static final String PREFS_NAME = "MyPregs";
  private GetTask getTask;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getTask = new GetTask();
    getTask.execute();
  }

  public class GetTask extends AsyncTask<Void, Void, ReturnModel> {
    @Override
    protected ReturnModel doInBackground(Void... params) {
      return load();
    }

    @Override
    protected void onPostExecute(ReturnModel result) {

      if(result.passworderror == true)
      {
        Toast.makeText(getApplicationContext(), "fail", Toast.LENGTH_SHORT).show();
      }
      else
      {
        Toast.makeText(getApplicationContext(), "yaya", Toast.LENGTH_SHORT).show();

        ListView lv = getListView();
        lv.setTextFilterEnabled(true);

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, result.getheadlines());
        setListAdapter(adapter);
        lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {
                Toast.makeText(getApplicationContext(), "Yaya, we clicked on something", Toast.LENGTH_LONG).show();
                // TODO Auto-generated method stub

            }
          });
      }
    }
  }

  private ReturnModel load() {
    ReturnModel returnModel = new ReturnModel();

    BufferedReader in = null;
    String data = null;
    Bundle gotData = getIntent().getExtras();
    if (gotData != null) {
      GotPass = gotData.getString("key!");
      GotUname = gotData.getString("key!!");
    }

    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    String username = settings.getString("key1", null);
    String password = settings.getString("key2", null);
    // username = "irock97"; // unremark to test like you got username from prefs..
    if (username != null  && username.equals("irock97")) {
      returnModel.setPassworderror(false);
    }
    else 
    {
      returnModel.setPassworderror(true);
      return returnModel;
    }

    HttpClient httpclient = new DefaultHttpClient();

    /* login.php returns true if username and password is equal to saranga */
    HttpPost httppost = new HttpPost("http://gta5news.com/login.php");

    try {
      // Add user name and password
      List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
      nameValuePairs.add(new BasicNameValuePair("username", username));
      nameValuePairs.add(new BasicNameValuePair("password", password));
      httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

      // Execute HTTP Post Request
      Log.w("HttpPost", "Execute HTTP Post Request");
      HttpResponse response = httpclient.execute(httppost);
      in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
      StringBuffer sb = new StringBuffer("");
      String l = "";
      String nl = "";
      while ((l = in.readLine()) != null) {
        sb.append(l + nl);
      }
      in.close();
      data = sb.toString();


      List<String> headlines = new ArrayList<String>();
      headlines.add(data);
      returnModel.setheadlines(headlines);

    }
    catch (ClientProtocolException e) {
      e.printStackTrace();
    }
    catch (IOException e) {
      e.printStackTrace();
    }

    return returnModel;
  }


  public class ReturnModel {
    private List<String> headlines;
    private boolean passworderror;

    public List<String> getheadlines() {
      return headlines;
    }

    public void setheadlines(List<String> headlines) {
      this.headlines = headlines;
    }

    public boolean getPassworderror() {
      return passworderror;
    }

    public void setPassworderror(boolean passworderror) {
      this.passworderror = passworderror;
    }
  }

}
  • 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-02T15:12:40+00:00Added an answer on June 2, 2026 at 3:12 pm

    Inflate an xml initial View (Pre setup that is equal on each of your dynamically created layouts) (inflate means format xml to View, simplified).

    LayoutInflater inflater = (LayoutInflater) MyApplication.getAppContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View newView = inflater.inflate(R.layout.your_layout, parent, false);
    

    now you can modify newView for your wishes and add new View Elements.

    To do so you have to reference your initial Layout, where you want to add things.

    For Example:

    LinearLayout myInitialLL = (LinearLayout) newView.findViewById(R.id.my_initial_ll);
    

    you can for example create a new Textview and add it to the myIniitalLL.

    TextView myTV = new TextView(this);
    myTv.setText("Test text");
    
    myInitialLL.addView(myTv);
    myInitialLL.requestLayout();
    

    you can now create custom private methods in your activity to create the logical part. This should be called in onItemClickListener.
    It is also possible to create dynamic TextViews via loop, if you dont now how much textviews you will need. I would preffer a ArrayList as parameter for that.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.