Android - List app icons in list and run selected - list

Im developing an Android app in eclipse.
I have a list showing the applications installed, the list is this:
//Listar apps instaladas
final ListView list1 = (ListView) findViewById(R.id.list1);
ArrayList results = new ArrayList();
PackageManager pm = this.getPackageManager();
Intent inte = new Intent(Intent.ACTION_MAIN, null);
inte.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> list = pm.queryIntentActivities(inte, PackageManager.PERMISSION_GRANTED);
for (ResolveInfo rInfo : list) {
results.add(rInfo.activityInfo.applicationInfo.loadLabel(pm).toString());
}
list1.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, results));
My questions are:
How I can do that instead of showing the icons name? if I do it
results.add(rInfo.activityInfo.applicationInfo.loadLabel(pm).toString());
show me "android.graphics.drawable # name of the application"
And how I can do to run the application by clicking on the list? I tried several attempts, but I make the application error.
Thanks!

results.add(rInfo.activityInfo.applicationInfo.loadLabel(pm).toString());
with this line of code I assume you're loading the label of the application, so perhaps you should try loadName or something, check what you can pick there anyway since I haven't done this myself before.
And which error do you get when you click the list? this would be helpful too :)

Related

Clicking the links having same link text in a loop using Seleneium webdriver in Python

I am using following code to scroll the page and follow the users on quora (Link to the page : http://www.quora.com/Kevin-Rose/followers), certain number of users are loaded after scrolling down, i am using the code given below :
# find all the follow buttons that are loaded
button = driver.find_elements_by_xpath("//a[contains(text(), 'Follow')]")
#number of users loaded
no_of_followers = len(button)
#execute the code till all the users are followed
while(no_of_followers > 0):
count = 0
#follow all the users loaded by clicking follow button in a loop
while(count < no_of_followers):
button[count].click()
time.sleep(30)
print count
count = count + 1
#scroll down
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
time.sleep(30)'
#find newly loaded users
button = driver.find_elements_by_xpath("//a[contains(text(), 'Follow')]")
time.sleep(30)
#tracking no of users left unfollowed
no_of_followers = len(button)
I am getting following error:
StaleElementReferenceException: Message: u'Element is no longer attached to the DOM' ; Stacktrace:
Edit 1: I tried using find_element_by_link _text, but apparently output object of the function is not a list of links which can be iterated.
The possible problem is # button[count].click().
I suggest you to use a for loop instead of while and increament that with an iterator.
Do something like
//you basically need to click on the first item all the time. The iterator should only control the number of iteration
Driver.FindElement(By.Xpath("Your Xpath")).Click();
Sorry, not an expert on python.

how to know if grid or list view is active with custom magento page

I have a custom product list page and i´m using the following code to show the pagenumbering and filters:
$pager = $this->getLayout()->createBlock('page/html_pager');
echo $this->getLayout()->createBlock('catalog/product_list_toolbar')->setChild('product_list_toolbar_pager', $pager)->setCollection($products)->toHtml();
If i'm changing the mode from grid to list view nothing happens.
How can i get the active mode (grid or list).
Magento normaly uses $this->getMode() but this one doesnt work.
I have fixed it with the following code:
$mode = $this->getLayout()->createBlock('catalog/product_list_toolbar')->setChild('product_list_toolbar_pager', $pager)->getCurrentMode();
Another solution,
if(Mage::getSingleton('catalog/session')->getDisplayMode())
{
$productListMode=Mage::getSingleton('catalog/session')->getDisplayMode();
}

How to dynamically change the list data when click on picker 'done' button in Sencha Touch

I am developing my application in Sencha touch. In that I have a list and Picker and I want to update the list data dynamically when selecting the picker i.e., I want to add data to list dynamically when tap on 'Done' button of Picker. I used some logic for this but this doesn't update the list content.
listeners: {
change: function(picker,value) {
textValue = picker.getValue()['name'];
var me = this,
nameList = this.down('#namesList');
nameList.add({fullname:textValue}) ;
}
}
When I update like this, it throws me the error that 'Uncaught TypeError: Cannot call method 'add' of null' eventhough 'namesList' is already defined. Please show me the way to solve this problem.
I would add a record to the data/store of the list, and then capture the list and refresh.
The issue there is that nameList isnt actually the list component.
Try adding for example an id to the list, and then in the picker change listener:
Ext.getCmp('mylist-id').refresh()
Hope it helps.

Flex Mobile Project: List

I am developing a mobile application in which I want to use a list which contains 400 rows. I got data from Sqlite database. When I run the application and click the button for the list, the list view is loading so slowly and takes about 45 seconds. I also tried getting data from an arraycollection inside the application but I had same problem. Is this normal? Any idea or advice for this issue?
sqlStat.text="SELECT City FROM Cities";
sqlStat.execute();
dataArray=sqlStat.getResult().data;
appModel=AppModel.getInstance();
if(appModel.cities == null)
{
appModel.cities = new ArrayCollection();
var obj:Object;
for( var i:int=0; i<dataArray.length; i++ )
{
obj = new Object();
obj.Name = dataArray[i].City
appModel.cities.addItem(obj);
}
myList.dataProvider=appModel.cities;
}
The OP wrote:
I solved my problem. ListForm component causes renderer problem. I used List component instead of that and created arrayCollection dataprovider for my list inside my class. It works faster than previous.

Launch Content Editor from code

I have an application that is creating an new item in Sitecore then opening up the Content Editor to that item, it is loading fine but whenever i try to open the html editor i get a 'NullReferenceException'. This is only happening when i launch the application in this method.
Source Code:
[Serializable]
public class PushToCMS : Command
{
public override void Execute(CommandContext context)
{
//Context.ClientPage.Start(this, "Action_PushToCMS");
Database dbCore = Sitecore.Configuration.Factory.GetDatabase("core");
Item contentEditor = dbCore.GetItem(new ID("{7EADA46B-11E2-4EC1-8C44-BE75784FF105}"));
Database dbMaster = Sitecore.Configuration.Factory.GetDatabase("master");
DatabaseEngines engine = new DatabaseEngines(dbMaster);
Item parentItem = dbMaster.GetItem("/sitecore/content/Home/Events/Parent/");
// Load existing related item if it exists
Event evt = new Event(new Guid(HttpContext.Current.Items["id"].ToString()));
Item item = dbMaster.SelectSingleItem("/sitecore/content/Home/Events/Parent/Item");
if (item == null)
item = CreateNewEvent(engine.DataEngine, parentItem, evt);
Sitecore.Text.UrlString parameters = new Sitecore.Text.UrlString();
parameters.Add("id", item.ID.ToString());
parameters.Add("fo", item.ID.ToString());
Sitecore.Shell.Framework.Windows.RunApplication(contentEditor, contentEditor.Appearance.Icon, contentEditor.DisplayName, parameters.ToString());
}
The only difference i can tell in the loading of the two methods is the url to the html editor, however i dont know where this is being defined or how i can control it.
Launched through normal method:
http://xxxx/sitecore/shell/default.aspx?xmlcontrol=RichTextEditor&da=core&id=%7bDD4372AC-5D37-4C9E-BBFA-C4E3E2A27722%7d&ed=F27055570&vs&la=en&fld=%7b60D10DBB-7CD5-4341-A960-C7AB10347A2C%7d&so&di=0&hdl=H27055699&us=%7b83D34C8A-4CC4-4CD9-A209-600D51B26AAE%7d&mo
Launched through RunApplication:
http://xxxx/layouts/xmlcontrol.aspx?xmlcontrol=RichTextEditor&da=core&id=%7bDD4372AC-5D37-4C9E-BBFA-C4E3E2A27722%7d&ed=F27055196&vs&la=en&fld=%7b60D10DBB-7CD5-4341-A960-C7AB10347A2C%7d&so&di=0&hdl=H27055325&us=%7b83D34C8A-4CC4-4CD9-A209-600D51B26AAE%7d&mo
any help on this would be greatly appreciated.
Phil,
If it is not too late for the answer... :)
It might be the case that you run this code without the permissions to read the core database. In this case, when you try to call contentEditor. you'll get NullReference. I would recommend you using another format of running the application - use another method:
Sitecore.Shell.Framework.Windows.RunApplication("Content Editor", parameters.ToString());
If this doesn't help, please attach the stack trace of the exception you get.
Hope this helps.