In the Repl I ran a query for "1" which is the current badge number on a tab.
This returned the below query, which you can see has the class _UIBadgeView.
However when I run a query for _UIBadgeView I get nothing.
I tried both app.Query("_UIBadgeView"); and app.Query(c => c.Class("_UIBadgeView"));
Any ideas how I can access the badge view?
{
Id => null,
Description => "<_UIBadgeView: 0x7e5cd380; frame = (49.5 2; 18 18); text = '1'; userInteractionEnabled = NO; layer = <CALayer: 0x7e5cceb0>>", Rect => {Width => 18, Height => 18, X => 145.5, Y => 621, CenterX => 154.5, CenterY => 630
},
Label => "1",
Text => "1",
Class => "_UIBadgeView",
Enabled => false
}
It is not obvious and maybe a bug, but underscore is not treated as an uppercase character. Use ClassFull instead of Class for an iOS class name that begins with underscore.
For iOS (first char lowercase): An element that has the class (or
super class) name of the given value prepended with "UI". Example:
button becomes UIButton. For iOS (first char uppercase): An element
that has the class (or super class) name of the given value.
AppQuery.Class
For iOS: An element that has the class (or super class) name of the given value.
AppQuery.ClassFull
Related
I have to create a view such as the iTunes Appstore with 3 different types of blocks: one for an image (ImageBlock), another for a list of object1 (Type1List) and a third for a list of object2 (Type2List).
I have functional MvxCollectionViewCells for all of the three, but I'd need to make an UICollectionView out of these three. I have an list of these lists (Items). A single list (Item) has a value called "type", which is an integer value 1, 2 or 3. I'd have to get this integer value for each Item and determine the NIB I want to use for this specific cell.
//Collection = UICollectionView
//ViewModel.Items = MvxObservableCollection<Item>
public override void ViewDidLoad()
{
base.ViewDidLoad();
var set = this.CreateBindingSet<View, ViewModel>();
// NIBs for types 1, 2 and 3 respectively
Collection.RegisterNibForCell(Type1List.Nib, Type1List.Key);
Collection.RegisterNibForCell(Type2List.Nib, Type2List.Key);
Collection.RegisterNibForCell(ImageBlock.Nib, ImageBlock.Key);
// This shows all items of type 1 correctly, and others using type 1 XIB with no contents
Source = new MvxCollectionViewSource(Collection, Type1List.Key);
// This gives a Null Reference Exception if used in place of the previous one
//Source = new MvxCollectionViewSource(Collection);
set.Bind(Source)
.To(vm => vm.Items);
// This takes the items and calculates the height for Collection in this View
// All types will differ in size
set.Bind(CollectionHeight)
.For(v => v.Constant)
.To(vm => vm.Items)
.WithConversion("IosCollectionHeight", Collection);
Collection.Source = Source;
// Set to 200 for now to see the cells
// TODO: set a working variable size
(Collection.CollectionViewLayout as UICollectionViewFlowLayout).ItemSize = new CoreGraphics.CGSize(UIScreen.MainScreen.Bounds.Width, 200);
//(Collection.CollectionViewLayout as UICollectionViewFlowLayout).EstimatedItemSize = new CoreGraphics.CGSize(UIScreen.MainScreen.Bounds.Width, 100);
set.Apply();
Collection.ReloadData();
}
So I have currently 2 problems:
I don't know how to use different NIBs by type for my UICollectionView
I don't know how to resize cells by type
All three cell NIBs are tested and working as intended, but this CollectionView is problematic.
-Pasketi
I have a declaration:
private var textField:TextField = new TextField(220, 35, "Tap to flip the text!", "Roboto", 22, 0xf1f1f1, false);
and then I have command:
textField.text.split("").reverse().join("");
which I found here: http://curtismorley.com/2007/10/18/as3-quicktip-reversing-a-string-with-one-line-of-code/
Can someone explain to me why this command doesn't reverse this string?
It does reverse the string. You don't see it though because you're not assigning the new value back to the textField.
textField.text = textField.text.split("").reverse().join("");
anything except an = after the text property will just be reading the value, not assigning it.
Also, your code isn't a valid textField, are you using some other extension of it?
private var textField:TextField = new TextField(220, 35, "Tap to flip the text!", "Roboto", 22, 0xf1f1f1, false);
Where did you take that declaration from? It should have thrown you an error immediately.
TextField () Constructor public function TextField()
Language Version: ActionScript 3.0 Runtime Versions: AIR 1.0, Flash
Player 9, Flash Lite 4
Creates a new TextField instance. After you create the TextField
instance, call the addChild() or addChildAt() method of the parent
DisplayObjectContainer object to add the TextField instance to the
display list.
The default size for a text field is 100 x 100 pixels.
Once you fix that, it will work just fine.
My Java ME MIDlet allows its user to change the language of the Midlet.
My code handles the internationalization, and it works fine for left-to-right languages.
But when the user changes the language to Right-To-Left language, the correct strings are being displayed but the screens remain left-justified.
In other words, the phone's locale is en_US and I don't want to change it.
I just want to change my MIDlet's locale.
What's the simplest way to dynamically change all the screens of the MIDlet to right-justify their content?
I don't mind if the solution involves having the user restart the application.
I also don't mind if the solution is proprietary to Nokia phones if there is no Java ME solution.
Assuming you are using LCDUI, by default StringItems and so on will be given a default layout based on the phone's locale. i.e. Item.LAYOUT_DEFAULT, this means a phone with an en_US locale will display items left to right whereas a phone with an ar_EG locale will display texts right to left.
It is however possible to force the layout to right justify texts using the setLayout() function:
StringItem myStringItem = new StringItem("Title", "The text I want to display", Item.PLAIN);
myStringItem.setLayout(Item.LAYOUT_RIGHT);
append(myStringItem );
You could easily create a singleton Settings class, which could hold a flag with the value to use for justification ( Item.LAYOUT_LEFT or Item.LAYOUT_RIGHT), and call it when setting the layout e.g.:
myStringItem.setLayout(Settings.getInstance().getJustification());
This could also be done in the constructor if you wish.
For low level Graphics the drawString() method can be used and the direction of the text altered, but you'll need to calculate the start point from the top right of your text not the top left
if (Settings.getInstance().getJustification() != Item.LAYOUT_RIGHT ) {
g.drawString("Some Text", x + TEXT_MARGIN , y ,Graphics.TOP | Graphics.LEFT);
} else {
// Arabic rendering of menu items - getWidth() is the maximum length
// of the line
g.drawString("Some Arabic Text", x + getWidth() - TEXT_MARGIN, y ,
Graphics.TOP | Graphics.RIGHT);
}
The simplest solution (which you have already rejected) would be to use Item.LAYOUT_DEFAULT throughout and alter the locale of the phone (of course), but you will still need to use an override for drawString() if you use low level graphics.
To check the correct justification I would enter the input locale using System.getProperty("microedition.locale") into a function such as this:
static final String[] RIGHT_TO_LEFT = {
"ar", // Arabic
"az", // Azerbaijani
"he", // Hebrew
"jv", // Javanese
"ks", // Kashmiri
"ml", // Malayalam
"ms", // Malay
"pa", // Panjabi
"fa", // Persian
"ps", // Pushto
"sd", // Sindhi
"so", // Somali
"tk", // Turkmen
"ug", // Uighur
"ur", // Urdu
"yi" // Yiddish
};
public static int getJustification(String locale) {
for (int index = 0; index < RIGHT_TO_LEFT.length; index++) {
if (locale.indexOf(RIGHT_TO_LEFT[index]) != -1) {
return Item.LAYOUT_RIGHT;
}
}
return Item.LAYOUT_DEFAULT;
}
NOTE: This has been answered as duplicate in the comment below.
I am having trouble getting RIA Services to return the data I need and not more than the data I need. I have a parent object (Project) which contains a number of children. One is a Component (one Component per Project). Another is a ProjectParticipant which needs to be limited based on the ParticipantRole, and I also need to grab the Person information (related to ProjectParticipant).
Here is some code I had earlier tried:
public IQueryable<IMSModel.Project> GetProjectHierarchy(String id)
{
return this.ObjectContext.Projects
.Include("Component")
.Include("ProjectParticipants")
.Include("ProjectParticipants.Person")
.Where(p => p.Program.ProgramType.lookupName == "EVDBE" &&
p.ProjectOrgs.Any(po => po.orgId == id) &&
p.ProjectParticipants.Any(pp => (pp.postId == id)) &&
p.ProjectParticipants.Any(pp => pp.PersonStatus.lookupName == "A") &&
p.ProjectParticipants.Any(pp => pp.ParticipantRole.participantInd == "Y"))
.OrderBy(p => new { p.fiscalYear, p.title })
.OrderByDescending(p => p.fiscalYear);
}
This doesn't work too badly, but I end up getting ProjectParticipant objects that I do not want. What I really want to do is limit the ProjectParticipant objects to those that have ParticipantRole.participantInd == "Y".
I tried another possible syntax for this, which is as follows:
public IQueryable<IMSModel.Project> GetProjectHierarchy(String id)
{
return this.ObjectContext.Projects
.Include("Component")
.Join(this.ObjectContext.ProjectParticipants
.Include("ProjectParticipants.Person")
.Where(
pp => pp.ParticipantRole.participantInd == "Y" &&
pp.postId == id &&
pp.PersonStatus.lookupName == "A"
)
, p => p.id
, pp => pp.projectId
, (p, pp) => p )
.Where(p => p.Program.ProgramType.lookupName == "EVDBE"
&& p.ProjectOrgs.Any(po => po.orgId == id));
}
I would think that this would return something a lot closer to what I might want. The only issue is that I don't get anything back in my hierarchical tree view. Something was returned, as blank locations were created for each record, but my bindings are not displaying any information. The bindings for the first example do show data, whereas the bindings for the second (more limited result set as I am not using Any()) does not show data.
I have been banging my head against this one for quite some time now and cannot resolve. Any assistance would be great.
I have a statement in my template.php file that directs to a custom node-myccktype.tpl.php. I've added some DIV's so that I can have a two column node/add form, but now I'm trying to find print my fields, but can't seem to get it.
I'm basically using something like this:
<?php print form_render($form['field_sr_minutes']); ?>
which I came across on a Drupal Blog, but I get call to undefined function "form_render"
I am using the var_dump to get the the array below, how can I print my node title(subject) field without printing everything else? This way I can put each form field in the column I want Instead of the standard vertical drupal form.
Array
(
[0] => Array
(
[#type] => textfield
[#title] => Subject
[#required] => 1
[#default_value] =>
[#maxlength] => 255
[#weight] => -5
[#post] => Array
(
)
[#programmed] =>
[#tree] =>
[#parents] => Array
(
[0] => title
)
[#array_parents] => Array
(
[0] => title
)
[#processed] => 1
[#description] =>
[#attributes] => Array
(
)
[#input] => 1
[#size] => 60
[#autocomplete_path] =>
[#process] => Array
(
[0] => form_expand_ahah
)
[#name] => title
[#id] => edit-title
[#value] =>
[#defaults_loaded] => 1
[#sorted] => 1
)
Sorry. Because of your .tpl file name I thought that you were trying to theme a node view. For forms, the right function is not form_render but drupal_render. You can basically write things like echo drupal_render($form['field_sr_minutes']) . In the very end, remember to do a drupal_render($form) to render all the remaining things which you have not rendered by hand. This will be required to have the form working correctly.
Old Answer
The node.tpl.php and other content
type specific .tpl.php get passed the
full node object in $node. Try doing
a
drupal_set_message(print_r($node,TRUE))
on top of your tpl file. From that you
can figure out the exact path of the
values you need to print.
For example, title of the node will be
available in $node->title. However you
should be careful to always use
check_plain if you are going to
print user submitted values. For CCK
fields, you can find the already
filtered values in $node-><field
name>[0][view].