Monday, January 28, 2013

Combo box / Drop down list box in Android


As usual doing something simple in Android is frustrating - this time: a simple Combo (or DropDownList). The little and important tweak - calling "setDropDownViewResource" to set the style of the items in the dialog box.

XML:
<spinner id="@+id/spinner" layout_width="wrap_content" android:layout_height="wrap_content" />

Code to add the data:
  1. Spinner spinner = (Spinner)this.findViewById(R.id.spinner);  
  2. ArrayAdapter<String> adapter = new ArrayAdapter<String>(  
  3.         this,  
  4.         android.R.layout.simple_spinner_item,  
  5.         new String[] { "1""2""3" });  
  6. adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);  
  7. spinner.setAdapter(adapter);  

Tuesday, January 22, 2013

Using Google Maps in Android

Google Maps is one of the many applications bundled with the Android platform. In addition to simply using the Maps application, you can also embed it into your own applications and make it do some very cool things. In this article, I will show you how to use Google Maps in your Android applications and how to programmatically perform the following:
  1. Change the views of Google Maps
  2. Obtain the latitude and longitude of locations in Google Maps
  3. Perform geocoding and reverse geocoding
  4. Add markers to Google Maps

Saturday, January 19, 2013

How to set environment variables in Windows 7 for Java

Environmental variables are used by the operating system to save settings (default values, locations of resources) to be used by Windows or by processes launched by users.
There are two types of environmental variables:
  • user variables that are specific to a particular Windows user account;
  • system variables are always visible, regardless of the used user account.

Even if these variables are usually defined and initialized automatically when you install the system or other applications, there are situations in which the user must manually define them to put at the disposal of applications.
The considered scenario is to set environment variables to enable the compilation and execution of Java applications from the command line (command prompt) or by using an IDE like Eclipse. By installing the Java SDK, system variables about the location of executables (compiler, java virtual machine) are not defined or initialized automatically.
Testing is done by opening command prompt (Start -> cmd) and trying to launch the compiler with the command

Thursday, January 3, 2013

Hàm lấy ảnh thumbnails từ hình ảnh trong bài viết,featured image và youtube

Chèn vào file functions.php trong thư mục theme

Code:
// Note that your theme must support post thumbnails for this function to work.
// If you are getting an error try adding add_theme_support('post-thumbnails'); to your functions. php file
function vp_get_thumb_url($text, $size){
    global $post;
    $imageurl="";

    // Check to see which image is set as "Featured Image"
    $featuredimg = get_post_thumbnail_id($post->ID);
    // Get source for featured image
    $img_src = wp_get_attachment_image_src($featuredimg, $size);
    // Set $imageurl to Featured Image
    $imageurl=$img_src[0];

    // If there is no "Featured Image" set, move on and get the first image attached to the post
    if (!$imageurl) {
        // Extract the thumbnail from the first attached imaged
        $allimages =&get_children('post_type=attachment&post_mime_type=image&post_parent=' . $post->ID );

        foreach ($allimages as $img){
            $img_src = wp_get_attachment_image_src($img->ID, $size);
            break;
        }
        // Set $imageurl to first attached image
        $imageurl=$img_src[0];
    }

    // If there's no image attached or inserted in the post, look for a YouTube video
if (!$imageurl){
   // look for traditional youtube.com url from address bar
preg_match("/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/watch(\?v\=|\/v\/)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $text, $matches2);
$youtubeurl = $matches2[0];
    if ($youtubeurl)
$imageurl = "http://i.ytimg.com/vi/{$matches2[3]}/1.jpg"; 
// look for YouTube embed
   else preg_match("/([a-zA-Z0-9\-\_]+\.|)youtube\.com\/(v\/)([a-zA-Z0-9\-\_]{11})([^<\s]*)/", $text, $matches2);
$youtubeurl = $matches2[0];
   if ($youtubeurl)
        // Get the thumbnail YouTube automatically generates
        // '0' is the biggest version, use 1 2 or 3 for smaller versions
$imageurl = "http://i.ytimg.com/vi/{$matches2[3]}/1.jpg"; 
}
    // If there is no image attached to the post, look for anything that looks like an image and get that
    if (!$imageurl) {
        preg_match('/<\s*img [^\>]*src\s*=\s*[\""\']?([^\""\'>]*)/i' ,  $text, $matches);
        $imageurl=$matches[1];
    }
// If there is no youtube thumbnail, show a default image
    if (!$imageurl) {
        $imageurl= "http://killthebeat.com/wp-content/themes/buzznews/images/thumbz.jpg";
    }

    // Spit out the image path
    return $imageurl;
}

Wednesday, January 2, 2013

Tạo File DEB và Source Cydia

Chúng ta hãy khái niệm sơ qua về cách thức hoạt động của Cydia và cách vận hành của nó!

Cydia được viết bởi Jay Freeman (saurik) cũng là 1 trong những thành viên trong iphone dev team dựa trên nền tảng unix có tính tương thích cao với HĐH MAC OS của iPhone giúp dễ dàng quản lý cũng như cài đặt các chương trình của hãng thứ 3 (liên quan tới System, nên ko được cấp phép bới Apple) nói cách khác Cydia được cài cho những máy đã Jailbreak.
Kiếm tiền từ wap 
Thay thế Installer: như chúng ta đã biết Installer 1 chương trình quá quen thuộc với những người dùng iPhone FW 1.x. Nay khi FW 2.x 3.x ra đời Cydia đã thay thế cho Installer 1 cách toàn diện.

Những gói cài đặt trên Installer là dạng .zip khi được down về thì Installer sẽ giải nén nó ra vào đường dẫn tương ứng. Cydia cũng giống vậy nhưng gói cài đặt của nó là dạng deb (DEBIAN) 1 dạng của Linux.

Cydia hoạt động bằng cách Down 1 file Packages.gz hoặc Packages.bz2 của 1 host bất kỳ và phân tích giải nén nó ra được 1 file Packages bao gồm những thông tin của toàn bộ những Packages trên Source.

Ta có 1 host làm Source cho Cydia Cydia Repo khi ta add Source này vào Cydia thì Cydia sẽ Down file Packages.bz2 của host này về giải nén được file Packages và phân tích thông tin của từng gói cài đặt bao gồm:

Popular Posts