[android-developers] Dynamic ArrayAdapter and Spinner

2010-09-14 Thread Sara Khalatbari
Hi all

I need to create an  ArrayAdapter and a Spinner that are totally dynamic and
have nothing to do with the layout file.

So I am trying to do something like:

Spinner spinnerListID;
spinnerListID = new Spinner (this);
String[] array_spinner = new String[5];
array_spinner[0]="1";
array_spinner[1]="2";
array_spinner[2]="3";
array_spinner[3]="4";
array_spinner[4]="5";
ArrayAdapter adapter = new ArrayAdapter(this, ?, array_spinner);
spinnerListID.setAdapter(adapter);
ll.addView(editTextInputListID);


But I can not see how I can create an ArrayAdapter that does not need
a textViewResourceId?

As it is described
http://developer.android.com/reference/android/widget/ArrayAdapter.html: It
looks like it is a needed constructor parameter.
Or should I not use this way at all?

Thank you,
Sara

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Dynamic Buttons Onclick

2010-09-07 Thread Sara Khalatbari
Thanks Kostya,

Does anyone also happen to know how can we make a button that has been
created dynamically
set to "wrap_content" (as we do in the static mode) to make the
*button fit* neatly
around the text?

Thank you,
Sara


On Tue, Sep 7, 2010 at 2:11 PM, Kostya Vasilyev  wrote:

>  Right.
>
> The scope of aUIXButton is the inside of the loop, it does not persist
> until the later point in time when OnClickListener subclass is invoked.
>
> Moreover, the value of aUIXButton refers to all five buttons, one by one,
> as the loop rolls.
>
> Use this instead:
>
>
>  aUIXButton.setOnClickListener(new OnClickListener() {
> @Override
> public void onClick(View arg0) {
> *Button button = (Button) arg0;
> button.setText("Y");
> *}});
>
> -- Kostya
>
> 07.09.2010 16:00, Sara Khalatbari пишет:
>
> Hi.
>
>  I have some dynamic buttons that are being generated inside a for loop.
>
>   for (int i = 0; i < 5 ; i++) {
>
>
>>   Button aUIXButton = new Button (SecondPage.this);
>
>  aUIXButton.setClickable(true);
>
>  aUIXButton.setText("X");
>
>
>>   aUIXButton.setOnClickListener(new OnClickListener() {
>
>  @Override
>
>  public void onClick(View arg0) {
>
>  aUIXButton.setText("Y");
>
>  }});
>
>  }
>
>
>  This is not working. It says
> "Cannot refer to a non-final variable aUIXButton inside an inner class
> defined in a different method"
>
>  & wants to change the modifier of  aUIXButton to final & I don't want to
> do that.
>
>  Does anyone know how can I fix this?
>
>  Thank you,
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
>
>
> --
> Kostya Vasilyev -- WiFi Manager + pretty widget -- 
> http://kmansoft.wordpress.com
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Dynamic Buttons Onclick

2010-09-07 Thread Sara Khalatbari
Hi.

I have some dynamic buttons that are being generated inside a for loop.

for (int i = 0; i < 5 ; i++) {


> Button aUIXButton = new Button (SecondPage.this);

aUIXButton.setClickable(true);

aUIXButton.setText("X");


> aUIXButton.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View arg0) {

aUIXButton.setText("Y");

}});

}


This is not working. It says
"Cannot refer to a non-final variable aUIXButton inside an inner class
defined in a different method"

& wants to change the modifier of  aUIXButton to final & I don't want to do
that.

Does anyone know how can I fix this?

Thank you,

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Add CheckBox on buttonclick - Dynamic Mode

2010-08-24 Thread Sara Khalatbari
Hi all

I am trying to run the attached code to display a checkbox when I click on
the buttons.

My program crashes though and I can not see why.

Do you have any idea?

Thank you,
Sara

package Dynamiclayout.example.com;

import Dynamiclayout.example.com.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ScrollView;
import android.widget.LinearLayout;
import android.widget.Button;
import android.widget.CheckBox;

public class Dynamiclayout extends Activity {
ButtonbuttonGET,buttonPost;
CheckBox checkbox1;
LinearLayout ll = null;

/** Called when the activity is first created. */
@Override


public void onCreate(Bundle savedInstanceState) {
 class clicker implements Button.OnClickListener {
@Override
public void onClick(View v) {
if(v==buttonGET){
checkbox1 = new CheckBox (null);
checkbox1.setText("I'm dynamic!");
ll.addView(checkbox1);
}
if(v==buttonPost){
checkbox1.setText("I'm very dynamic!");
ll.addView(checkbox1);

}
}
 }

super.onCreate(savedInstanceState);
setContentView(R.layout.main);

ScrollView sv = new ScrollView(this);
//LinearLayout ll = new LinearLayout(this);
ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
sv.addView(ll);

buttonGET = new Button(this);
buttonGET.setText("GET");
ll.addView(buttonGET);
buttonGET.setOnClickListener(new clicker());

buttonPost = new Button(this);
buttonPost.setText("POST");
ll.addView(buttonPost);
buttonPost.setOnClickListener(new clicker());

this.setContentView(sv);


}
}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Dynamiclayout.java
Description: Binary data


[android-developers] How to use the httpdelete on a list?

2010-08-16 Thread Sara Khalatbari
Hi all,

Say the server is providing you with an xml list which looks like
this:


0
-

1
Unknown owner
Randomly generated list

-

-

1
Bananas
open

-

2
Bread
open

-

3
Süssmost
open




How can you write a httpdelete request that would delete the "Bread"?

So that when you GET
NodeList items = doc.getElementsByTagName("name");

You see only
Banana and Süssmost.

Thank you,
Sara

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en