View Controls..

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

View Controls..

Postby bqbqhahabq » Tue Nov 17, 2009 7:10 am

Hi, good morning.

I have a question about view.

What I want to do is that use 'xml' file firstly to create and show basic layout of screen.

And then soon (secondly) , add many views like TextView ... by hard-coding (programmatically)

How Can I do this ??

if I use setContentView(xxxx); twice, first one will be deleted..

How can this issue solved ?!??!?
bqbqhahabq
Junior Developer
Junior Developer
 
Posts: 18
Joined: Tue Nov 17, 2009 6:57 am

Top

Postby qlimax » Wed Nov 18, 2009 12:07 pm

link your layout "lay" by findviewbyid..

then

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. TextView t = new TextView( this );
  2.  
  3. t.setText( "6 1 tofaz." );
  4.  
  5. LinearLayout.LayoutParams tlp =
  6.  
  7. new LinearLayout.LayoutParams( LayoutParams.FILL_PARENT,
  8.  
  9. LayoutParams.WRAP_CONTENT );
  10.  
  11.  
  12.  
  13. lay.addView( t, tlp );
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


bye
¯`·.¸¸.><((((º>¯`·.¸¸. ><((((º>
User avatar
qlimax
Master Developer
Master Developer
 
Posts: 271
Joined: Mon Aug 31, 2009 10:54 am
Location: Swiss

Postby ianwong » Fri Nov 20, 2009 8:00 am

Hi,

I recently have the same question.

I did try what qlimax suggested but the problem is as the nature of
LinearLayout, the origin XML usually should already filled up the
screen. A new View added to it will be sent out of screen.
Is there any way to insert a view? Or I have to use AbsoluteLayout
instead?

Thanks,
Ian
ianwong
Freshman
Freshman
 
Posts: 6
Joined: Fri Nov 20, 2009 7:46 am

Postby qlimax » Fri Nov 20, 2009 11:57 am

ianwong wrote:Hi,

I recently have the same question.

I did try what qlimax suggested but the problem is as the nature of
LinearLayout, the origin XML usually should already filled up the
screen. A new View added to it will be sent out of screen.
Is there any way to insert a view? Or I have to use AbsoluteLayout
instead?

Thanks,
Ian


if the linearlayout has enought space to place the child view, it should work.
if the linla is full of things, then is normal that the view is added out of the screen... then you have to solve it with a scrollview.

can you explain your problem with an example?
bye
¯`·.¸¸.><((((º>¯`·.¸¸. ><((((º>
User avatar
qlimax
Master Developer
Master Developer
 
Posts: 271
Joined: Mon Aug 31, 2009 10:54 am
Location: Swiss

Postby ianwong » Sat Nov 21, 2009 8:32 pm

Hi qlimax,

What I'm trying to do is kinda help screen which is
on top and half transparent of my current screen
showing what to do. So I want some textviews
on top of my full screen.

Regards,
Ian Wong
ianwong
Freshman
Freshman
 
Posts: 6
Joined: Fri Nov 20, 2009 7:46 am

Postby qlimax » Sun Nov 22, 2009 10:57 am

if I understand correct, you need a sort of dialog like this, to show an help ?

Image
(img found on google)
¯`·.¸¸.><((((º>¯`·.¸¸. ><((((º>
User avatar
qlimax
Master Developer
Master Developer
 
Posts: 271
Joined: Mon Aug 31, 2009 10:54 am
Location: Swiss

Top

Postby ianwong » Mon Nov 23, 2009 3:03 am

Hi qlimax,

This is exactly what I do now after I gave up my original thought .
I put a screenshot image in the icon and have text message for help.

My original plan was to have some direct pointer to show the user
what function in specific area does. I did try on what add views before
but it seems not possible to do what's in my mind with LinearLayout.

I do have a new thought now though I'm not sure it works or not.
I may try to have a new activity, set it half transparent, work on
that activity.

Regards,
Ian Wong
ianwong
Freshman
Freshman
 
Posts: 6
Joined: Fri Nov 20, 2009 7:46 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google [Bot] and 6 guests