RSS

Category Archives: Java

Google Book Search in C#: A step by step walk-through tutorial


Several years earlier, I wrote a python script to perform ISBN book search: given the isbn number, the python script simply dumps the books title, publisher and author information, which are then used to rename the pdf that is downloaded into a more informational file name:

123456789a.pdf –> Elsevier_2010_A simple and effective geometric representation for irregular porous structure modeling.pdf

It is a handy script but unfortunately I lost it after a hard disk failure!

And then I decide to recover this from my brain, but I would like to implement it in another my favorite language, C#.

image

Source code of this project can be downloaded from GitHub here.

Read the rest of this entry »

Advertisements
 
14 Comments

Posted by on December 18, 2014 in Dotnet/C#, Java, Programming

 

Tags: , , , , , , , , , , , ,

Android: Change ProgressBar height


In Android development, you might dislike the very thin progress bar that Android defaults. For instance, in the below xml file, though you can specify the width and height, but you can see that width value functions, but the height value, no matter how large you specify, it remains slim horizontal bar:

image

image

image

To get the height value right, it is very simple:

change style=”?android:attr/progressBarStyleHorizontal” to
     
 style="@android:style/Widget.ProgressBar.Horizontal"

That is it! Happy coding!

 
2 Comments

Posted by on August 19, 2014 in Android, Java, Programming

 

Tags: , , , , , , , ,

Android EditText control: using old rectangle style


The latest android EditText looks like this (below left:

image   image

But I was asked to use old-style rectangle style (above right) to replace the current one. Here is how it is done:

  • Create a new xml file in res/drawable folder, which looks like this:

image

  • Next, in your activity’s layout xml file, append below 1-line code:

image

Note I: you don’t have to create the above xml file, and you can download this 14-line rect_tex_edit.xml file and directly put it in your project’s res/drawable/ folder.

Note II : the below code might be useful, which makes the cursor and text more legible and clear in the view:

android:textColor=”@android:color/black”
android:textCursorDrawable=”@null”

That is it. Enjoy this trick!

 
5 Comments

Posted by on August 26, 2013 in Android, Java, Programming

 

Tags: , , , ,

Java Socket handshaking: the simplest example


In an earlier post, I have discussed how to implement socket communication with python. I recently was asked to implement similar functions, but in Java. Here is how I did that.

  • Create a new Java project, let’s name it JSocketClient;
  • Create another Java project, let’s name it JSocketServer;
  • In both projects, create an App class, and add a static Main function respectively:

    image

Read the rest of this entry »

 
Leave a comment

Posted by on August 20, 2013 in Java, Programming

 

Tags: , , , ,