meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
android:questions [2010/03/17 17:32]
vadim.m
android:questions [2010/03/19 06:52]
vadim.m
Line 1: Line 1:
 ====== Android Coding Questions ====== ====== Android Coding Questions ======
-==== How to add question ? ==== 
  
-Log into wiki, find this question (index) page, and add a question beginning the this page, after first headline. + 
 +==== Where's an example of layout used by ListActivity? ==== 
 <code> <code>
-  ==== My Problem ? ==== + 
-  How to get functionality X to work ?+<?xml version="1.0" encoding="utf-8"?> 
 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
 +         android:orientation="vertical" 
 +         android:layout_width="fill_parent"  
 +         android:layout_height="fill_parent" 
 +         android:paddingLeft="8dp" 
 +         android:paddingRight="8dp"> 
 +  
 +    <ListView android:id="@id/android:list" 
 +               android:layout_width="fill_parent"  
 +               android:layout_height="fill_parent" 
 +               android:layout_weight="1" 
 +               android:drawSelectorOnTop="false"/> 
 +  
 +  <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/AnotherTextView"></TextView> 
 +  
 +</LinearLayout> 
 </code> </code>
 +
 ==== How do I start another activity? ==== ==== How do I start another activity? ====
  
Line 15: Line 34:
  
 ==== How to add EditText fields to the table's cells? ==== ==== How to add EditText fields to the table's cells? ====
 +<code>
 +<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
 + android:scrollbars="vertical" android:layout_height="fill_parent"
 + android:layout_width="fill_parent" android:stretchColumns="*">
 + <TableRow android:id="@+id/tablerow1">
 + <EditText android:text="1." android:id="@+id/EditText01"
 + android:editable="false"></EditText>
 + <EditText android:id="@+id/EditText11"></EditText>
 + <EditText android:id="@+id/EditText21"></EditText>
 + </TableRow>
 +</TableLayout>
 +</code>
 +
 +==== How to get Eclipse and Android work in Ubuntu? ====
 +For eclipse you need to use sun java packages (gcc gjc java is installed by default but it does not seem to work well)
 +  * https://help.ubuntu.com/community/Java
 +  * get JDK (SDK) package as well
 +
 +Ubuntu 9.10 repositories have Eclipse 3.5.1. It does not work with Android SDK. Get newer Eclipse. Version 3.5.2 seem to work.
 +  * http://www.eclipse.org => Download => Eclipse for Java (or Java EE (not nessessary)).
 +  * Extract it to your self installed software place (eg. /opt) and link eclipse start program to some place in your PATH.
 +
 +Follow general android install [[setup|instructions]].
 +
 +
 +==== How to save XML file after editing (f.e. adding new child) - what class to use? ====
 +
 +To use XmlSerializer is one option to save XML into readable form (string or file). 
 +
 +See the following link [[http://www.ibm.com/developerworks/xml/library/x-android/|Working with XML on Android]] if that is helpful.
 +
 +<code>
 +
 +private String writeXml(List<Message> messages){
 +    XmlSerializer serializer = Xml.newSerializer();
 +    StringWriter writer = new StringWriter();
 +    try {
 +        serializer.setOutput(writer);
 +        serializer.startDocument("UTF-8", true);
 +        serializer.startTag("", "messages");
 +        serializer.attribute("", "number", String.valueOf(messages.size()));
 +        for (Message msg: messages){
 +            serializer.startTag("", "message");
 +            serializer.attribute("", "date", msg.getDate());
 +            serializer.startTag("", "title");
 +            serializer.text(msg.getTitle());
 +            serializer.endTag("", "title");
 +            serializer.startTag("", "url");
 +            serializer.text(msg.getLink().toExternalForm());
 +            serializer.endTag("", "url");
 +            serializer.startTag("", "body");
 +            serializer.text(msg.getDescription());
 +            serializer.endTag("", "body");
 +            serializer.endTag("", "message");
 +        }
 +        serializer.endTag("", "messages");
 +        serializer.endDocument();
 +        return writer.toString();
 +    } catch (Exception e) {
 +        throw new RuntimeException(e);
 +    } 
 +}
 +
 +</code>
 +
 +==== Does anybody know how to launch another application, e.g. "YouTube" from your own program? ====
 +I know how to launch web-browser, if smb needs I can explain. Also I've installed some applications to the emulator, except YouTube :(. By the way we know how to send data from one activity to another and few other features, that could be useful just ask, may be we've faced with it! Vadim.
 +
 +==== How to add question ? ====
 +
 +Log into wiki, find this question (index) page, and add a question beginning the this page, after first headline. 
 +<code>
 +  ==== My Problem ? ====
 +  How to get functionality X to work ?
 +</code>
 +
  
 ==== How to answer a question ? ==== ==== How to answer a question ? ====