Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Contributor
jimmyd25
Posts: 43
Registered: ‎11-17-2010
My Device: Not Specified
Accepted Solution

Format large text blocks to fit qnx list

Hey Everyone,

 

I was stuck with a small formatting problem when it comes to qnx.ui.listClasses. I'm using a qnx list container to display items from an RSS feed into a list. However, some of the comments and text blocks being fed from the RSS feed into the list are long and the containers width is not long enough to show the whole message, which makes the message disappear at the list border.

 

I was wondering if there is a way to format the content being fed into the list to start on a new line within the container as soon as it hits the edge, so it doesn't disappear at the border.

 

Any help is appreciated. Thank you!

Please use plain text.
Contributor
jimmyd25
Posts: 43
Registered: ‎11-17-2010
My Device: Not Specified

Re: Format large text blocks to fit qnx list

One more thing - I was also wondering if it is possible to clear the dataprovider contents fed into a list(text content).

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Format large text blocks to fit qnx list

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Format large text blocks to fit qnx list

[ Edited ]

hey jimmy,

 

the only thing that comes to mind is make a custom cellrenderer class and modify the look of each row in the list. once you are in the cellrenderer class you can wrap each of the text in a Label class and set a width to match the width of the list and then set each of their properites for wordWrap to true.

 

Edit #1: Also i just want to make a note that you should look for the functions onAdded and onRemoved if you want to directly edit each of the rows of the list from your custom cell renderer class. here is a link to something me and jtegen were working on a couple of weeks ago in regards to cellrenderes:

 

http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/Renderer-for-DropDown-working/m-p...

 

it deals with the dropdowncellrenderer but its the same concept. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Contributor
jimmyd25
Posts: 43
Registered: ‎11-17-2010
My Device: Not Specified

Re: Format large text blocks to fit qnx list

Thanks so much Jrab, as well as John! Jrab that post you and John made on cellrenderers is going to help me big time, so I appreciate it!

 

John I did try the .dataProvider.removeAll(); function to get rid of text within the list, however that did not work. I was thinking I might have luck if I used a loop to delete text within the list while length > 0. I am also going to try the onAdded and onRemoved functions. I'll post my progress if I make any.

 

Thanks again!

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Format large text blocks to fit qnx list

hey jimmy,

 

no problem at all! now in regards to removing all items from your list. try to invoke the removeAll() method on your list object. this should clear your list. for example:

 

 

(...)

listOfThings = new List();

(...)

listOfThings.dataProvider = dp;

(...)

listOfThings.removeAll();

(...)

 

the reason why when u invoke the method on the actual dataprovider object it doesnt work is because when you set the dataprovider on your list object it takes just the values of hte dataprovider versus taking the entire object as a reference. so when you do something to dataprovider object it does not effect the list's dataprovider property. so try it out and see how it goes. good luck!

 

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Contributor
jimmyd25
Posts: 43
Registered: ‎11-17-2010
My Device: Not Specified

Re: Format large text blocks to fit qnx list

hey JRab,

 

Thanks for the suggestion. I tried it out, however that did not work. What I did though is I set the dataprovider value to null when I wanted the list cleared.

 

example: (Where content is the array dataprovider)

 

content = null;

content = new Array();

 

I made this call each time I needed to populate the list with new content.

 

Thank you for the suggestions though - your help is always appreciated!

 

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Format large text blocks to fit qnx list

hey Jimmy,

 

thanks for the kudo! but i dont understand why it didnt work.. guess practice beats theory huh? hah. im gonna have to test this out and see. thanks for the update though ill let u know what i find.

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Contributor
jimmyd25
Posts: 43
Registered: ‎11-17-2010
My Device: Not Specified

Re: Format large text blocks to fit qnx list

Ya I was surprised it didn't work as well. I'm guessing it has something to do with the fact that the list I was populating consisted of dynamic items. Not entirely sure though. Let me know if it ends up working for you, ty.

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Format large text blocks to fit qnx list

hey Jimmy,

 

so i ran the following program:

 

 

package
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.MouseEvent;
	
	import qnx.ui.buttons.LabelButton;
	import qnx.ui.data.DataProvider;
	import qnx.ui.listClasses.AlternatingCellRenderer;
	import qnx.ui.listClasses.List;
	import qnx.ui.listClasses.ListSelectionMode;
	
	[SWF(width="1024", height="600", backgroundColor="#CCCCCC", frameRate="30")]
	public class RandomTests extends Sprite
	{
		private var myList:List;
		private var dp:Array;
		private var myBtn:LabelButton;
		
		public function RandomTests()
		{
			myList = new List();
			dp = new Array();
			
			for (var i:int = 0; i < 10; i++)
			{
				dp.push({label: "Test Item " + i});
			}
			
			myList.dataProvider = new DataProvider(dp);
			myList.width = 200;
			myList.height = 500;
			myList.selectionMode = ListSelectionMode.SINGLE;

			
			addChild(myList);
			
			myBtn = new LabelButton();
			myBtn.label = "Click Me To Clear";
			myBtn.setPosition(250, 0);
			myBtn.addEventListener(MouseEvent.CLICK, clearList);
			
			addChild(myBtn);
			
			
		}
		public function clearList(e:MouseEvent):void
		{
			myList.removeAll();
			dp.splice(0);
			
			for (var i:int = 0; i < 10; i++)
			{
				dp.push({label: "New Test Item " + i});
			}
			
			myList.dataProvider = new DataProvider(dp);
		}
	}
}

 

so it first populates a list of ten items and presents the orginal list. then you click on the clear button and it clears the list and re-populates the list with new items. so it works on my end. maybe you are populating your list differently like u said?

 

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.