I am developing a game similar to geochallenge game in facebook. here i am unable to decide whether i should use Image buttons/Grid view/Image view or some other else....?
please can any one suggest in this regard...
My requirement is
I should store some number of images. And at particular time I should randomly display three distinct images, and these images will be replaced by other images when any of those images is clicked. The the images should not be repeated.
can you help me please.
Now i am using Image button concept but the images are repeating in three image buttons. But i should get distinct images on each image button.
after a long struggle I was able to get a solution. Here's what I did.
I have a flags array "Country[]" and three Image Buttons declared as ImageButton array bt[]={id1,id2,id3};, which I use with the following code:
public void randomDisplay()
{
L=Country.length;
for(int i=0; i<3;i++)
{
int random=rand.nextInt(L-1);
if(i==0)
id1=Country[random];
if(i==1)
id2=Country[random];
if(i==2)
id3=Country[random];
id=getResources().getIdentifier(Country[random], "drawable", getPackageName());
bt[i].setImageResource(id);
String temp=Country[L-1];
Country[L-1]=Country[random];
Country[random]=temp;
L=L-1;
}
}
The above code will shift one country name to the end of the country array at each repetition, and decrements the country array length. This will avoid the duplicate names on ImageButtons. If you have any question please let me know...
Related
here's the code:
$.each(app.rows, function(index, obj) {
$.each(obj, function(ind, ob) {
if (ind == 'hasStuff') {
if (ob == 1) {
app.rows[index][ind] = '<i class="las la-list-ul small"></i><img src="../_img/yes.png" alt"yes"/>';
} else {
app.rows[index][ind] = '<i class="las la-ban small"></i><img src="../_img/no.png" alt"no"/>';
}
}
})
})
what it renders is the actual text, not the image it points to. can't get either font icons or images to display, just the literal text. the array renders out properly in all other respects, but not this part. i'm kinda stumped. and nothing i've found seems to be of help.
the paths are confirmed correct, please don't ask me about that.
EDIT: as i commented below, but will include here for easier viewing, this code REPLACES values from an array. the original array comes from a database query and, as this is done ad hoc, i can't declare it beforehand. also, for 200,000+ records, not feasible.
EDIT2: this piece of code INTERCEPTS THE RESULTS OF A DATABASE QUERY, swaps the boolean -1- for an image and an icon, then loops through a v-for in the template. this is pretty basic stuff. i just don't know why Vue isn't rendering this out. when the v-for loops through the modified array, it doesn't render either the image or the icon, it just outputs the raw HTML. whyyyy????
what am i missing?
I am writing an UI test case, in which I need to perform an action, and then on the current page, scroll the only UITableView to the bottom to check if specific text shows up inside the last cell in the UITableView.
Right now the only way I can think of is to scroll it using app.tables.cells.element(boundBy: 0).swipeUp(), but if there are too many cells, it doesn't scroll all the way to the bottom. And the number of cells in the UITableView is not always the same, I cannot swipe up more than once because there might be only one cell in the table.
One way you could go about this is by getting the last cell from the tableView. Then, run a while loop that scrolls and checks to see if the cell isHittable between each scroll. Once it's determined that isHittable == true, the element can then be asserted against.
https://developer.apple.com/documentation/xctest/xcuielement/1500561-ishittable
It would look something like this (Swift answer):
In your XCTestCase file, write a query to identify the table. Then, a subsequent query to identify the last cell.
let tableView = app.descendants(matching: .table).firstMatch
guard let lastCell = tableView.cells.allElementsBoundByIndex.last else { return }
Use a while loop to determine whether or not the cell isHittable/is on screen. Note: isHittable relies on the cell's userInteractionEnabled property being set to true
//Add in a count, so that the loop can escape if it's scrolled too many times
let MAX_SCROLLS = 10
var count = 0
while lastCell.isHittable == false && count < MAX_SCROLLS {
apps.swipeUp()
count += 1
}
Check the cell's text using the label property, and compare it against the expected text.
//If there is only one label within the cell
let textInLastCell = lastCell.descendants(matching: .staticText).firstMatch
XCTAssertTrue(textInLastCell.label == "Expected Text" && textInLastCell.isHittable)
Blaines answer lead me to dig a little bit more into this topic and I found a different solution that worked for me:
func testTheTest() {
let app = XCUIApplication()
app.launch()
// Opens a menu in my app which contains the table view
app.buttons["openMenu"].tap()
// Get a handle for the tableView
let listpagetableviewTable = app.tables["myTableView"]
// Get a handle for the not yet existing cell by its content text
let cell = listpagetableviewTable.staticTexts["This text is from the cell"]
// Swipe down until it is visible
while !cell.exists {
app.swipeUp()
}
// Interact with it when visible
cell.tap()
}
One thing I had to do for this in order to work is set isAccessibilityElement to true and also assign accessibilityLabel as a String to the table view so it can be queried by it within the test code.
This might not be best practice but for what I could see in my test it works very well. I don't know how it would work when the cell has no text, one might be able to reference the cell(which is not really directly referenced here) by an image view or something else. It's obviously missing the counter from Blaines answer but I left it out for simplicity reasons.
I've got an Array with 17 web links of images
var products:Array;
trace(products)
// Ouput :
"http://www.myWebsite.com/zootopia.jpg"
"http://www.myWebsite.com/james.jpg"
"http://www.myWebsite.com/tom.jpg"
..etc
If I do products[10].movieimage; the output will be the 9th link (something like : "http://www.myWebsite.com/lalaland.jpg")
I'm looking for downloading every images without a dialog box.
I manage to do so for 1 image with the specific link, like that :
function saveImage (event:Event):void {
var stream:URLStream = new URLStream();
var image1:File = File.documentsDirectory.resolvePath("test.jpg");
var fileStream:FileStream = new FileStream();
stream.load(new URLRequest("http://www.myWebsite.com/lalaland.jpg"));
stream.addEventListener(Event.COMPLETE, writeComplete);
function writeComplete(evt:Event):void {
var fileData:ByteArray = new ByteArray();
stream.readBytes(fileData,0,stream.bytesAvailable);
fileStream.openAsync(image1, FileMode.UPDATE);
fileStream.writeBytes(fileData,0,fileData.length);
fileStream.close();
trace("writeComplete");
trace(image1.url);
}
}
Question : Is there a way to download all the images with the web links of my products array ? (and if images already exist, replace them. I could use if (image1.exists){ if (image2.exists){ ..etc for each image. But maybe there is a simplier solution)
If you could show me how, with a bit of code, I could that.
Also, note that I'd like to load the images then in Uiloader, like that :
function loadImages():void {
uiloader1.source = image1.url;
uiloader2.source = image2.url;
etc...
}
Don't over think it. You have your array of images. You have your tested routine for saving one image. Now put it together:
Some function initializes things and kicks it off.
Either splice out (or pop out) an item on the array – OR use a index var to access an item in the array
Pass that to your download function.
When the download completes either pop another item off the array OR increment your index. But first you would test if array.length== 0 OR `index > array.length. If either is true (depending on which method you use), then you are done.
If you want to get fancy you can show a progress bar and update it each time your download completes.
So I have this movie review website. I am using Linq to XML to get a movie review element and its contents (Title, Review and rating). The rating comes from a dropdownlist, and the following code:
var rating = "";
for (int i = 0; i < (int)film.Element("rating"); i++)
{
rating += "<img src='../bilder/star.png'/>";
}
Prints images equal to the value chosen in the dropdownlist. Now to the problem. I am sending this in as an assignment, so i have to .zip the website folder to send it in. When i copy the website folder, put it into another folder on the desktop and try to run it, it gives me no images. Just blank/broken document images equal to the amount chosen in the dropdown list, it is not getting the star.png image right, even if i have this in a file called images/star.png.
Anyone have any solution to this?
I have a jqgrid with a subgrid.
I am attempting to apply different colors to master and detail grids. I have two rules: the first one is to alternate odd and pair colors and the other one is to apply specific CSS to the row, based on values of a specific field.
Both master & details grid, contains the following gridComplete functions, where obviously childnodes index varies cause tables contains different fields:
gridComplete: function () {
var _rows = $(".jqgrow");
for (var i = 0; i < _rows.length; i++) {
_rows[i].attributes["class"].value += " " + _rows[i].childNodes[4].textContent;
_rows[i].attributes["class"].value += " " + _rows[i].childNodes[4].innerText;
}
applyZebra("jqTicketgrid");
}
applyZebra function provides to alternate odd/pair colours and has already been tested on another grid which not contains a subgrid.
For the record, I found above solutions in other solved questions of this forum, and both works with "simple" jqgrids (not master/detail).
PROBLEM
The master grid is formatted only when I click to expand the detail rows, while detail subgrid never alternate colours, neither apply format based on cell contents...
Where I am wrong? Pheraps I must intercept another event which is not gridComplete? Otherwise with grid&subgrids it's impossible to use _rows[x] & childNodes[y] attributes?
Please ask for clarifications, if needed, thx.
Thanks in advance!
I suppose the error in your code is that you use $(".jqgrow") instead of $(".jqgrow", this) where this inside of gridComplete will be either DOM element of the <table> of the grid or the subgid (I suppose you use grid as subgrid).
Additionally I would not recommend you to use you current code at all. It's much more effective and simple to to use cellattr. The rawObject parameter allow you access all other cells of the current row. In the answer you will find an example of implementation.