[android-developers] Re: Move buttons within Layout

2010-02-19 Thread Kritzli

Did you mean HelloLinearLayout or the API Demos ?
Well, I had a look at both. But as I mentioned before, in my opinion I
can't create a layout in XML.
It need to be dynamically.

Maybe I'm thinking in the wrong direction...

-- 
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] Re: Move buttons within Layout

2010-02-19 Thread skink


On Feb 19, 2:16 pm, Kritzli pfister.ta...@googlemail.com wrote:
 Did you mean HelloLinearLayout or the API Demos ?
 Well, I had a look at both. But as I mentioned before, in my opinion I
 can't create a layout in XML.
 It need to be dynamically.

 Maybe I'm thinking in the wrong direction...

no, i mean LinearLayout.java, one of std android's layout:

http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/widget/LinearLayout.java;h=6cc794b97ac94e7d193099dc075d767355bd82bd;hb=HEAD

pskink

-- 
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] Re: Move buttons within Layout

2010-02-17 Thread Kritzli
I'm still stuck on this problem. I tried to solve it by making the
whole activity dynamic. But still the button is positioned at top
left.
I can't see why

ok.layout(k.getLeft(), k.getTop(), k.getRight(),k.getBottom());

isn't repositioning the button, even if it shows the right Values on
LogCat.

I really need some help on that !


On 10 Feb., 14:35, Kritzli pfister.ta...@googlemail.com wrote:
 Ok. Here's some more information about my App.
 I'm going to create a keyboard app. Or rather an App where you can
 define your own keyboard. Therefore I have two Activities A and B.

 Activity A:
 Here I want to create a single key. This is currently realized by
 configuring a button.
 The buttons size can be customized with a progress bar. One for height
 and one for width. Also some letters/text can be added.
 Then, height, width and the text of the button is send via an Intent
 to Activity B.

 Activity B:
 On Activity B the current Button gets its properties out of the Intent
 and via Gesture you can set it somewhere on the screen.
 Afterwards the button get saved in an Arraylist.
 Everytime I call Activity B the Arraylist is read and the buttons
 should be shown on their position as before defined.
 So the screen should be filled with buttons until the keyboard is
 ready.

 Then I want to create the keyboard (but I have no idea how yet ;) )

 But as mentioned before, after reading the Arraylist the buttons loose
 their position.

 And here's the whole code of Activity B:

 package example.com.fpa;

 import java.util.ArrayList;
 import java.util.Iterator;

 import android.app.Activity;
 import android.content.Intent;
 import android.gesture.Gesture;
 import android.gesture.GestureLibraries;
 import android.gesture.GestureLibrary;
 import android.gesture.GestureOverlayView;
 import android.gesture.Prediction;
 import android.gesture.GestureOverlayView.OnGesturePerformedListener;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup.LayoutParams;
 import android.widget.Button;
 import android.widget.RelativeLayout;
 import android.widget.Toast;

 public class keyboard_view extends Activity implements
 OnGesturePerformedListener {

         protected Button key_button;
         protected GestureLibrary mLibrary;
 //      protected keys other_keys;
         protected int position;
         public static ArrayListButton keyList = new ArrayListButton();
         public Iterator iter;
         public static RelativeLayout rel_layout;

         /**
          * @param args
          */
          public void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                 setContentView(R.layout.keyboard_view);

                 final Intent intent = new Intent(this, fpa.class);

                 rel_layout = new RelativeLayout(this);

                 final Button back_button = (Button)
 findViewById(R.id.back_button);
                 final Button accept_button = (Button)
 findViewById(R.id.accept_button);
                 key_button = (Button) findViewById(R.id.key_button);

                 mLibrary = GestureLibraries.fromRawResource(this,
 R.raw.gestures);
                 if (!mLibrary.load()) {
                     finish();
                 }

                 GestureOverlayView gestures = (GestureOverlayView)
 findViewById(R.id.gestures);
                 gestures.addOnGesturePerformedListener(this);

 key_button.setHeight(getIntent().getExtras().getInt(height));
                 key_button.setWidth(getIntent().getExtras().getInt(width));

 key_button.setText(getIntent().getExtras().getCharSequence(letter));

                 back_button.setOnClickListener(new OnClickListener(){
                         public void onClick(View v){
                                 //Perform action on clicks

                                         intent.putExtra(height, 
 key_button.getHeight());
                                         intent.putExtra(width, 
 key_button.getWidth());
                                         startActivity(intent);
                         }
                 });

                 accept_button.setOnClickListener(new OnClickListener(){
                         public void onClick(View v){
                                 //Perform action on clicks
                                 keyList.add(key_button);
                                         intent.putExtra(height, 
 key_button.getHeight());
                                         intent.putExtra(width, 
 key_button.getWidth());
                                         startActivity(intent);
                         }
                 });

                 if(keyList.isEmpty() == false){
                         for (iter = keyList.iterator(); iter.hasNext();){

                                 Button k =  (Button) iter.next();
                                 Button ok = new Button(this);

        

Re: [android-developers] Re: Move buttons within Layout

2010-02-17 Thread Mark Murphy
Kritzli wrote:
 I'm still stuck on this problem. I tried to solve it by making the
 whole activity dynamic. But still the button is positioned at top
 left.
 I can't see why
 
 ok.layout(k.getLeft(), k.getTop(), k.getRight(),k.getBottom());
 
 isn't repositioning the button, even if it shows the right Values on
 LogCat.
 
 I really need some help on that !

Moving a widget requires altering the layout rules that control where
the widget is, via the appropriate *.LayoutParams object.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Warescription: Three Android Books, Plus Updates, One Low Price!

-- 
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] Re: Move buttons within Layout

2010-02-17 Thread skink


Kritzli wrote:
 I'm still stuck on this problem. I tried to solve it by making the
 whole activity dynamic. But still the button is positioned at top
 left.
 I can't see why

 ok.layout(k.getLeft(), k.getTop(), k.getRight(),k.getBottom());

 isn't repositioning the button, even if it shows the right Values on
 LogCat.

instead of using RelativeLayout i'd use custom one extending ViewGroup

pskink

-- 
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] Re: Move buttons within Layout

2010-02-17 Thread Kritzli
Thank you for your replies. But I still don't get it...

Could you please explain how I should use the LayoutParams ?
I thouht I only can use them with FILL_PARENT, WRAP_CONTENT and
addRule() but not to define a position with specific values.

@pskink
How would you do that ?



On 17 Feb., 15:23, skink psk...@gmail.com wrote:
 Kritzli wrote:
  I'm still stuck on this problem. I tried to solve it by making the
  whole activity dynamic. But still the button is positioned at top
  left.
  I can't see why

  ok.layout(k.getLeft(), k.getTop(), k.getRight(),k.getBottom());

  isn't repositioning the button, even if it shows the right Values on
  LogCat.

 instead of using RelativeLayout i'd use custom one extending ViewGroup

 pskink

-- 
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] Re: Move buttons within Layout

2010-02-17 Thread Mark Murphy
Kritzli wrote:
 Thank you for your replies. But I still don't get it...
 
 Could you please explain how I should use the LayoutParams ?
 I thouht I only can use them with FILL_PARENT, WRAP_CONTENT and
 addRule() but not to define a position with specific values.

That's because you can't define a position with specific values.

Step #1: Design the layout in XML the way the widgets are originally.
You probably already have this already.

Step #2: Create an equivalent layout in XML the way the widgets will be
after your move.

Step #3: Figure out the right changes to LayoutParams, margins, and
whatnot to change your widgets, in Java, from the state the widgets
start in (Step #1) to the state you want the widgets in after the move
(Step #2).

You cannot just arbitrarily position widgets wherever you want -- their
position is dictated by their layouts.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in US: 26-30 April 2010: http://onlc.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


[android-developers] Re: Move buttons within Layout

2010-02-17 Thread skink


On Feb 17, 4:58 pm, Mark Murphy mmur...@commonsware.com wrote:

 You cannot just arbitrarily position widgets wherever you want -- their
 position is dictated by their layouts.


unless he writes own custom layout extending ViewGroup -
RelativeLayout in his case is pretty useless

pskink

-- 
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] Re: Move buttons within Layout

2010-02-17 Thread Mark Murphy
skink wrote:
 On Feb 17, 4:58 pm, Mark Murphy mmur...@commonsware.com wrote:
 You cannot just arbitrarily position widgets wherever you want -- their
 position is dictated by their layouts.

 
 unless he writes own custom layout extending ViewGroup -

Agreed. Got any well-documented examples?

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in US: 26-30 April 2010: http://onlc.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


[android-developers] Re: Move buttons within Layout

2010-02-17 Thread skink


On Feb 17, 5:08 pm, Mark Murphy mmur...@commonsware.com wrote:
 skink wrote:
  On Feb 17, 4:58 pm, Mark Murphy mmur...@commonsware.com wrote:
  You cannot just arbitrarily position widgets wherever you want -- their
  position is dictated by their layouts.

  unless he writes own custom layout extending ViewGroup -

 Agreed. Got any well-documented examples?

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://twitter.com/commonsguy

 Android Training in US: 26-30 April 2010:http://onlc.com

err, well, LinearLayout.java ? :-)

pskink

-- 
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] Re: Move buttons within Layout

2010-02-17 Thread Kritzli
 That's because you can't define a position with specific values.

Um, why not ? It worked well in onGesturePerformed-Method. That's why
I'm thinking it also should be working.

And I can't create a layout in XML, cause I don't know how many and
where the widgets would be moved.


 err, well, LinearLayout.java ? :-)

ok, will have a look at it.

-- 
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] Re: Move buttons within Layout

2010-02-10 Thread Kritzli
Ok. Here's some more information about my App.
I'm going to create a keyboard app. Or rather an App where you can
define your own keyboard. Therefore I have two Activities A and B.

Activity A:
Here I want to create a single key. This is currently realized by
configuring a button.
The buttons size can be customized with a progress bar. One for height
and one for width. Also some letters/text can be added.
Then, height, width and the text of the button is send via an Intent
to Activity B.

Activity B:
On Activity B the current Button gets its properties out of the Intent
and via Gesture you can set it somewhere on the screen.
Afterwards the button get saved in an Arraylist.
Everytime I call Activity B the Arraylist is read and the buttons
should be shown on their position as before defined.
So the screen should be filled with buttons until the keyboard is
ready.

Then I want to create the keyboard (but I have no idea how yet ;) )

But as mentioned before, after reading the Arraylist the buttons loose
their position.

And here's the whole code of Activity B:

package example.com.fpa;

import java.util.ArrayList;
import java.util.Iterator;

import android.app.Activity;
import android.content.Intent;
import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.Prediction;
import android.gesture.GestureOverlayView.OnGesturePerformedListener;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.Toast;

public class keyboard_view extends Activity implements
OnGesturePerformedListener {

protected Button key_button;
protected GestureLibrary mLibrary;
//  protected keys other_keys;
protected int position;
public static ArrayListButton keyList = new ArrayListButton();
public Iterator iter;
public static RelativeLayout rel_layout;

/**
 * @param args
 */
 public void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
setContentView(R.layout.keyboard_view);


final Intent intent = new Intent(this, fpa.class);

rel_layout = new RelativeLayout(this);

final Button back_button = (Button)
findViewById(R.id.back_button);
final Button accept_button = (Button)
findViewById(R.id.accept_button);
key_button = (Button) findViewById(R.id.key_button);

mLibrary = GestureLibraries.fromRawResource(this,
R.raw.gestures);
if (!mLibrary.load()) {
finish();
}

GestureOverlayView gestures = (GestureOverlayView)
findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);


key_button.setHeight(getIntent().getExtras().getInt(height));
key_button.setWidth(getIntent().getExtras().getInt(width));

key_button.setText(getIntent().getExtras().getCharSequence(letter));



back_button.setOnClickListener(new OnClickListener(){
public void onClick(View v){
//Perform action on clicks

intent.putExtra(height, 
key_button.getHeight());
intent.putExtra(width, 
key_button.getWidth());
startActivity(intent);
}
});

accept_button.setOnClickListener(new OnClickListener(){
public void onClick(View v){
//Perform action on clicks
keyList.add(key_button);
intent.putExtra(height, 
key_button.getHeight());
intent.putExtra(width, 
key_button.getWidth());
startActivity(intent);
}
});


if(keyList.isEmpty() == false){
for (iter = keyList.iterator(); iter.hasNext();){


Button k =  (Button) iter.next();
Button ok = new Button(this);

ok.setHeight(k.getHeight());
Log.i(Button K, Höhe:  + k.getHeight());
Log.i(Button OK, Höhe:  + ok.getHeight());

ok.setWidth(k.getWidth());
Log.i(Button K, Weite:  + k.getWidth());
Log.i(Button OK, Weite:  + ok.getWidth());
ok.setText(k.getText());
 

[android-developers] Re: Move buttons within Layout

2010-02-08 Thread Kritzli
 You cannot pass a Button via an Intent.

You're right. I only pass the height, width and text of the button I
customized in Activity A.

 Activity B cannot modify the UI of Activity A. Activity B cannot safely
 reuse the widgets of Activity A.

I don't want to modify the UI of Activity A. Activity B has its own UI
or rather Activity B's Ui is made of those buttons.  Therefore I want
to move and show the buttons on Activity B.

Maybe I schould post some more code for clarification ?



On 8 Feb., 14:14, Mark Murphy mmur...@commonsware.com wrote:
  There are two Activities (Activity A and B). At Activity A I customize
  a button and pass it on Activity B via an intent.

 You cannot pass a Button via an Intent.

  On Activity B I move
  the button somewhere on the screen.

 Activity B cannot modify the UI of Activity A. Activity B cannot safely
 reuse the widgets of Activity A.

  Any suggestion and hints how this could be solved would be
  appreciated !

 Give Activity B its own widgets, independent of those from Activity A,
 positioned where they are supposed to be from the outset.

 --
 Mark Murphy (a Commons Guy)http://commonsware.com
 Android App Developer Books:http://commonsware.com/books.html

-- 
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