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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:04:58+00:00 2026-06-15T06:04:58+00:00

i try make spinner and button with clickHandler this is my nyoba.java import android.app.Activity;

  • 0

i try make spinner and button with clickHandler

this is my nyoba.java

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;

public class nyoba extends Activity {
    String[] nama_hari = {"Senin", "Selasa", "Rabu","Kamis","Jum'at","Sabtu","Minggu"};
    /** Called when the activity is first created. */
     Spinner  spinner1;
     Button btnSubmit;
     TextView textView1;
     String tes;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btnSubmit = (Button)findViewById(R.id.btnSubmit);
        textView1 = (TextView)findViewById(R.id.textView1);
        spinner1 = (Spinner)findViewById(R.id.spinner1);
        ArrayAdapter<String> aa = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, nama_hari);
           aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner1.setAdapter(aa);
    }
    public void onItemSelected(AdapterView<?> arg0, View arg1,  
            int arg2, long arg3) {  
            tes =  nama_hari[arg2]; 
    }  
    public void clickHandler(View view){
        switch (view.getId()){
        case R.id.btnSubmit:
         textView1.setText(tes); 
            break;
}
    }
}

and this is my main.xml file

<?xml version="1.0" encoding="utf-8"?>
<ScrollView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:fillViewport="true">
  <RelativeLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:background="#ffffff">



        <LinearLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:padding="10dip"
          >

          <Spinner
        android:id="@+id/spinner1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <Button
        android:id="@+id/btnSubmit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="clickHandler"
        android:text="Submit" />

    <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                 />


        </LinearLayout>


  </RelativeLayout>
</ScrollView>

but when i run it to emulator,and i choose 1 option in spinner and click the button , the TextView doesn’t show up the word from spinner which i choose

(for example, i choose “senin” at spinner, and click the button, but the text “senin” doesn’t appear in the TextView )

i check DDMS and there are no error…..

is the code wrong?
can you help me please which one is wrong?

Thank anyway….

  • 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-15T06:04:59+00:00Added an answer on June 15, 2026 at 6:04 am

    I think you don’t set the selection listener on your spinner.

    But actually you can just retrieve the spinner’s selected position with getSelectedItemPosition in the click handler of your button:

    Try this:

    public void clickHandler(View view) {
        switch (view.getId()) {
        case R.id.btnSubmit:
            textView1.setText(nama_hari[spinner1.getSelectedItemPosition()]);
            break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to make an Android application which communicates with a non-standard ISO15693 (NFC-V)
I have been using the Learning Java 2nd Edtion book to try make my
This is really strange behavior. When I try make a search using findItemsAdvanced to
i try to make my screen blinking like this: for (int i=0;i<10;i++) { targetView.setBackgroundColor(Color.BLUE);
I try to make this implementation of a multimap in C++, but I run
I'll try make this short. I want to get a list of browsers installed
I'm trying to make a mapactivity with both a mapview and a spinner. This
i just try to make a simple offline currency converter using 2 spinner. i
I try to make my ListBox connected to ObservaleCollection be more efficient so for
I try to make an ActiveX by C# with COM-visible. It is a Windows

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.