Thursday, December 8, 2011

Android listview Header & footer

//footer view
View fv = inflater.inflate(R.layout.font_popup_footer, null, false);
Button btnCancel = (Button)fv.findViewById(R.id.btnpopup_ancel);
btnCancel.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
popup.dismiss();

}
});

//Header view
View hv = inflater.inflate(R.layout.font_popup_header, null, false);
TextView headtv = (TextView)hv.findViewById(R.id.txt_Popup_header);

headtv.setTypeface(TsciiTypeface.getTypeface(this));
btnCancel.setTypeface(TsciiTypeface.getTypeface(this));
fontSizeListView.addHeaderView(hv);
//fontSizeListView.addFooterView(fv);

Friday, August 5, 2011

Linear search in Erlang

-module search.
-export ([search/2]).

search([],N)->
"Not Found";
search([X|L],X) ->
"Found";
search([X|L],N) ->
search(L,N).

Monday, July 11, 2011

Invoke a java method from c++

#include
#include
#include
#include
#include

JNIEnv* create_vm(JavaVM ** jvm) {

JNIEnv *env;
JavaVMInitArgs vm_args;
JavaVMOption options[3];
options[0].optionString = "-Djava.class.path=D:\\java\\Excel\\Excel\\dist\\Excel.jar"; //Path to the java source code

vm_args.version = JNI_VERSION_1_6; //JDK version. This indicates version 1.6
vm_args.nOptions = 1;
vm_args.options = options;
vm_args.ignoreUnrecognized = 0;

int ret = JNI_CreateJavaVM(jvm, (void**)&env, &vm_args);
if(ret < 0) printf("\nUnable to Launch JVM\n"); return env; } int main(int argc, char* argv[]) { std::ifstream l_ifstream; char * l_buffer; int l_lenght; l_ifstream.open("ExampleSimple.xml"); l_ifstream.seekg(0, std::ios::end); l_lenght = l_ifstream.tellg(); l_ifstream.seekg(0, std::ios::beg); l_buffer = new char[l_lenght+1]; l_ifstream.read(l_buffer, l_lenght); l_ifstream.close(); l_buffer[l_lenght]='\0'; JNIEnv *env; JavaVM * jvm; env = create_vm(&jvm); if (env == NULL) return 1; jclass l_excelCreatorClass = NULL; jmethodID l_methodCreateWorkBook = NULL; jobject l_inpuXmlString = NULL; jobject l_outPutFile = NULL; jobject l_boolReturn = NULL; jstring l_jxmlstring = env->NewStringUTF(l_buffer);
jstring l_joutFile = env->NewStringUTF("ExampleCPP.xlsx");


l_excelCreatorClass = env->FindClass("com/excel/xl/TTExcelCreator");

if (env->ExceptionOccurred()) {
env->ExceptionDescribe();
}

if(l_excelCreatorClass)
{
l_methodCreateWorkBook = env->GetStaticMethodID(l_excelCreatorClass, "createWorkBook", "(Ljava/lang/String;Ljava/lang/String;)Z");

}
else
{
printf("\nUnable to find the requested class\n");
}

if(l_methodCreateWorkBook)
{

jboolean l_jbresult =(jboolean)env->CallBooleanMethod(l_excelCreatorClass,l_methodCreateWorkBook,l_jxmlstring,l_joutFile);

if(l_jbresult)
{
printf("success");
}
else
{
printf("error");
}
}
else
{
printf("\nUnable to find the requested method\n")
}
}

Tuesday, June 7, 2011

Useful links

Tutorials

Java

Enterprise JavaBeans Tutorial
JavaBeans Short Course
Introduction to the JavaBeans API
JDBC Short Course
Essentials of the Java Programming Language, Part 1
Essentials of the Java Programming Language, Part 2
Writing Advanced Applications for the Java Platform
Fundamentals of Java Security
Fundamentals of Java Servlets
Introduction to the Collections Framework
Introduction to CORBA
Fundamentals of RMI
Advanced
Introductory
Intermediate
Java Language Specification
Java Tutorial: Servlet Trail
Java Virtual Machine Specification (2nd Ed.)
Glossary of Java and Related Terms
The Java Language Environment
Java Look and Feel Design Guidelines
Story of a Servlet: An Instant Tutorial
Introduction to Java
Java2D: An Introduction and Tutorial
Java Servlet Tutorial
comp.lang.java FAQ
Brewing Java: A Tutorial
Shlurrrppp ... Java: The First User-Friendly Tutorial on Java
Swing Tutorial
Swing: A Quick Tutorial for AWT Programmers
Thinking in Java
Java RMI Tutorial
Java for C++ Programmers
The Advanced Jav/aJ2EE Tutorial
Hacking Java: The Java Professional's Resource Kit
JFC Unleashed
Java Developer's Guide
Java Developer's Reference
Sams Teach Yourself Java in 21 Days (Professional Reference Ed.)
Java Unleashed (2nd Ed.)
Java 1.1 Unleashed (3rd Ed.)
Java Game Programming Tutorial
Java Networking FAQ
Java Tutorial: A Practical Guide for Programmers
Sockets Programming in Java
Programming with Java - Part I
Programming with Java - Part II
Setting Up a Java Development Environment for Linux
Understanding Java
Beginner's Guide to JDK
GUI Development in Java
Java Servlets: An introduction to writing and running Java servlets on Linux

Wednesday, April 20, 2011

Android - Supporting Multiple Screens



Screen Size


      Android collapses all actual screen sizes into four generalized sizes: small, normal, large, and extra large. Applications can provide custom layouts for each of these four sizes — the platform transparently handles the rendering of the layouts at the actual screen size.

Density-independent pixel (dp)

     A virtual pixel unit that applications can use in defining their UI, to express layout dimensions or position in a density-independent way.

     The density-independent pixel is equivalent to one physical pixel on a 160 dpi screen, the baseline density assumed by the platform. At run time, the platform transparently handles any scaling of the dp units needed, based on the actual density of the screen in use. 

The conversion of dp units to screen pixels is simple:

              pixels = dps * (density / 160).

     For example, on 240 dpi screen, 1 dp would equal 1.5 physical pixels. Using dp units to define your application's UI is highly recommended, as a way of ensuring proper display of your UI on different screens