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 7783767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:56:08+00:00 2026-06-01T19:56:08+00:00

i made this code so i can send information to my website. Only now

  • 0

i made this code so i can send information to my website. Only now i want to load the category from a spinner i tried:

String mCategory = category.getItemAtPosition(what to put here?).toString();

i just don’t know how to, i’m hoping somebody does.

net.thinkbin;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

public class share extends Activity {

final Context context = this;
private Button post;
private EditText title, email, author, idea, submit;
Spinner category;

@Override
protected void onCreate(Bundle savedInstanceState) {

    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.share);

    Button view = (Button) findViewById(R.id.button1);
    view.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            startActivity(new Intent("net.thinkbin.TUTORIAL1"));
            overridePendingTransition(0, 0);
            finish();
        }
    });

    Button menu = (Button) findViewById(R.id.buttonhome);
    menu.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub

            // custom dialog
            final Dialog dialog = new Dialog(context);
            dialog.setContentView(R.layout.custom);

            // set the custom dialog components - text, image and button
            TextView text = (TextView) dialog.findViewById(R.id.text);
            text.setText("Loading...");
            ImageView image = (ImageView) dialog.findViewById(R.id.image);
            image.setImageResource(R.drawable.hourglass);

            dialog.show();
            Thread th = new Thread(new Runnable() {
                public void run() {

                    startActivity(new Intent("net.thinkbin.MENU"));
                    overridePendingTransition(0, 0);
                    dialog.dismiss();
                    finish();

                }
            });
            th.start();
        }
    });

    ArrayAdapter<CharSequence> adapter = ArrayAdapter
            .createFromResource(this, R.array.spinnerfood,
                    android.R.layout.simple_spinner_item);
     adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    Spinner s = (Spinner) findViewById(R.id.spinner1);
    s.setAdapter(adapter);

    post = (Button) findViewById(R.id.post);
    title = (EditText) findViewById(R.id.titlefield);
    email = (EditText) findViewById(R.id.emailfield);
    author = (EditText) findViewById(R.id.authorfield);
    category = (Spinner) findViewById(R.id.spinner1);

    idea = (EditText) findViewById(R.id.ideafield);
    submit = (EditText) findViewById(R.id.submitfield);
    post.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            String mTitle = title.getText().toString();
            String mEmail = email.getText().toString();
            String mAuthor = author.getText().toString();
            String mCategory = category.getItemAtPosition().toString();
            String mIdea = idea.getText().toString();
            String mSubmit = submit.getText().toString();

            tryPost(mTitle, mEmail, mAuthor, mCategory, mIdea, mSubmit);
        }

    });
}



protected void tryPost(String mTitle, String mEmail, String mAuthor,
        String mCategory, String mIdea, String mSubmit) {
    HttpURLConnection connection;
    OutputStreamWriter request = null;

    URL url = null;
    String response = null;
    String parameters = "title=" + mTitle + "&email=" + mEmail + "&author="
            + mAuthor + "&category=" + mCategory + "&idea=" + mIdea
            + "&submit=" + mSubmit;

    try {
        url = new URL("http://www.thinkbin.net/include/api/share.php");
        connection = (HttpURLConnection) url.openConnection();
        connection.setDoOutput(true);
        connection.setRequestProperty("Content-Type",
                "application/x-www-form-urlencoded");
        connection.setRequestMethod("POST");

        request = new OutputStreamWriter(connection.getOutputStream());
        request.write(parameters);
        request.flush();
        request.close();
        String line = "";
        InputStreamReader isr = new InputStreamReader(
                connection.getInputStream());
        BufferedReader reader = new BufferedReader(isr);
        StringBuilder sb = new StringBuilder();
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
        // Response from server after login process will be stored in
        // response variable.
        response = sb.toString();
        // You can perform UI operations here
        Toast.makeText(this, "Succes! \n" + response, 0).show();
        isr.close();
        reader.close();
        startActivity(new Intent("net.thinkbin.MENU"));
        overridePendingTransition(0, 0);
        finish();

    } catch (IOException e) {
        // Error

    }
}
}
  • 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-01T19:56:10+00:00Added an answer on June 1, 2026 at 7:56 pm

    There’s a bunch of getSelected*() methods for the spinner. You probably want getSelectedItem().

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

Sidebar

Related Questions

How can I improve this code? What has made this long winded is the
I made this little function from code snippets around the net. It does what
i made a windows service & add project installer.in which only contain this code.
I made these changes appropriately: Now in 'app/controllers/ users_controller.rb ' I have this code:
I made this small location class so that I can better handle address information
I made this code with jQuery to fade images ( but not the one
I have made this code to open a database(created in SQLite browser) stored in
I am pretty new at C# and .NET, but I've made this code to
I have a problem, and I made this test code to show you my
Ok. I've made this awe-crap-code Exporting table to XLS (but still no idea how

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.