Here is a sample code to load XML layout files at runtime within your Android application. Basically, you have to have a Layout tag within your main XML file so that we get to have a placeholder to where we want to store our content.

Then in your code, follow this:

where a is the class that extends Activity. If you are going to place this code within your class that extends Activity, you don’t need to include the a. in the code. Of course, this does not restrict to LinearLayout alone. You can use all other layouts to add new Views as its content.

In Java, we use System.out or System.err.println() to show messages in the console. However, these don’t work in Android. These methods do not produce errors on compilation and does nothing during runtime. Chris Glover made this nifty class to actually be able to use System.out and System.err in your programming needs.


package ***;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import android.util.Log;

public class LogTool extends OutputStream {
  private ByteArrayOutputStream bos = new ByteArrayOutputStream();
  private String name;
  
  public LogTool(String name)   {
    this.name = name;
  }
  
  @Override
  public void write(int b) throws IOException {
    if (b == (int)'\n') {
  String s = new String(this.bos.toByteArray());
  Log.v(this.name, s);
  this.bos = new ByteArrayOutputStream();
    } else {
    this.bos.write(b);
    }
  }
}

At the startup of your code, use these lines


System.setErr(new PrintStream(new LogTool("System.err")));
System.setOut(new PrintStream(new LogTool("System.out")));

Then you can use System.out and System.err.println(). If you want to convert Exception messages generated from the printStackTrace() method of Exception classes, use this Exception to String method converter that I have.


public static String getExceptionStackTraceAsString(Exception exception) {
  StringWriter sw = new StringWriter();
  exception.printStackTrace(new PrintWriter(sw));
  return sw.toString();
}

GoDaddy is a hosting provider. You can either apply for a shared hosting or a dedicated server. Shared hosting means your hosting account is shared inside a server with all other customers. At least this is how I see it. A dedicated server meanwhile is like having your own server where you have total control over it. You can only access it remotely as the server itself does not have a physicality. Whatever you do with your server, just connect to it remotely. They also have this policy that since you are your own administrator, they won’t install things for you unless you apply for their maintenance fee. I encountered a problem with them before, took a lot of email exchanges before they finally gave me a good answer. If you need to add windows components like network services and others, you would need an OS installer for the components to be installed. They actually have an i386 folder in drive C in case you want to install or uninstall components. I was thinking of connecting my remote desktop application to my dvd-rom drive and install it from there but it was a good thing that GoDaddy placed that i386 folder in case we need something. Took probably 5 customer service agents exchanging emails till the last one gave me that tip, which solved my problem

Related Posts Plugin for WordPress, Blogger...