Extjs Static Combobox

This snippet show you a static combo

{
    xtype:'combo',
    fieldLabel:'Field Label',
    name:'theName',
    queryMode:'local',
    store:['1','2'],
    displayField:'Display Field',
    autoSelect:true,
    forceSelection:true
 }

Another alternative (1):

// The data store containing the list of statesvar 
pilihan = Ext.create('Ext.data.Store', {
    fields:['display','value'],
    data :[{"display":"Ya","value":"1"},
        {"display":"Tidak","value":"0"}]
    });

// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox',{ 
    fieldLabel:'Pilih', 
    store: pilihan, 
    queryMode:'local', 
    displayField:'display',
    valueField:'value', 
    renderTo:Ext.getBody()
});
 

Another alternative (2):

{
    xtype:'combo',
    fieldLabel:'Main',
    name:'main',
    queryMode:'local',
    anchor: '100%',
    store: Ext.create('Ext.data.Store', {
        fields: ['value', 'display'],
        data: [
            {
                "display": "Ya",
                "value": 1
            },
            {
                "display": "Tidak",
                "value": 0
            }
        ]
    }),
    displayField:'display',
    valueField: 'value',
    autoSelect:true,
    forceSelection:true
 }

Signing Your Android Applications

Yeah, it seems easy task for ‘real developers’ but not for beginner.
The easiest way to do this by Eclipse, so you must have an Eclipse before we start and ofcourse, you must have an Android project to signing. If you don’t have it, take a look into this tutorial.

 

(1) Start your Eclipse😀

 

(2) File – New – Other – Android Project from Existing Code

sign01

 

 

(3) Choose your Cordova application that you made before with Netbeans

sign02

 

(4) You can see MyApp and MyApp-CordovaLib.

sign03

 

Right click at MyApp – Android tools – Export signed application package and follow the step

(5) * Create new keystore

** Location: Your location file to store your new keystore

** Password: A password for your keystore

 

* Key Creation

** Alias: Alias your application

** Password: your keystore password

** Validity (years): Your validity years application

** Firstname and Lastname: You already know it😀

** […] Clear description and you can click next at the bottom of the form

 

* Destination apk: Fill with location and name for your apk and Finish.

sign09

 

Congratulation! you made it. You can upload MyApp.apk to your google play account.

 

Creating Android With Cordova 3.4.0 and Netbeans 8.0

Today, I just knew that Netbeans already have release version 8.0 and the other thing makes me happy is Cordova is easily configuring with this Netbeans.

In this post, I will lead you to create an Android application with Cordova 3.4.0 and Netbeans 8.0.

(1) Open your Netbeans 8.0 and File – New Project

(2) Choose an HMTL5 categories, Cordova Application project and next button.

cordova_01

 

(3) Fill in Project Name, Project Location, Project Folder and Next

cordova_02

 

(4) Choose Javascript Library and Next.

Notice; If you don’t add the JS library at this time, you can add later including it normally like creating an HTML project.

cordova_04

(5) Application ID, Application Name, Version and Finish

cordova_06

Wait for Netbeans upgrading Cordova platform.

 

(6) Run in Cordova Android Emulator

cordova_07

 

(7) Open your terminal in Netbeans. You can find it in Window – IDE Tools – Terminal.

Go to your Android SDK Linux tools folder

$ cd /home/kenzominang/android-sdk-linux/tools
$ ./android avd

cordova_09

 

(8) Choose one of AVD and start.

cordova_10

(9) And now you can build and start your Cordova application

cordova_12

 

That’s it. You have done creating an Android application with Netbeans.

If you have done developing it, you must sign in your application before uploading it into google play.

Updating Android SDK

Recently I am facing a problem when I create an Android application with Cordova platform. It happend when I execute $ cordova platform add android. The error line showing like this;

at /home/admin/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:87:29

This error message clear to me because when I opened check_reqs.js file, I found an information what I must do. Yeah, updating Android SDK or configuring Android SDK Path. But on this post, I will show you how to update The Android SDK;


$ cd android-sdk-linux/tools
$ ./android update sdk --no-ui

For further discussion, take a look at this

Concenate Array String Using StringBuilder in Java

My recent project is converting a PHP application into Java. I have found this code in PHP. I think this piece of code is interesting because I have found this code a lot from the application.

Below code used for tricky query block in PHP

$nu_filters = preg_replace('/[^a-zA-Z0-9]+/', ' ', $filter);
$search_words = explode(" ", $nu_filters);
$thisWhere = "";
 foreach($search_words as $sword)
 {
     $thisWhere .= " content_all like '%".$sword."%' $operator_concat ";
 }
$thisWhere_count = strlen($thisWhere);
 //echo $thisWhere;
$where = " (".substr($thisWhere, 0, $thisWhere_count - 4).") ";
return $where;

And this is the Java code using StringBuilder:

public class TheQuery {
    public StringBuilder secondWhereLogic(String filter, String operator_concat) {

        String nu_filter = filter.replaceAll("/[^a-zA-Z0-9]+/", " ");

        String[] search_words = nu_filter.split(" ");

        StringBuilder newStr = new StringBuilder();

        for(int i = 0; i < search_words.length; i++) {
            newStr.append(" content_all like '%"+search_words[i]+"%' or ");
        }
        return newStr;
    }
}

Thats it…🙂