2013년 1월 29일 화요일
2013년 1월 24일 목요일
2013년 1월 23일 수요일
2013년 1월 22일 화요일
android listview scrollto certain position(top)
final ListView listView = (ListView) findViewById(R.id.myListView);
Collections.addAll(values, values2);
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, android.R.id.text1, values);
listView.setAdapter(adapter);
listView.post( new Runnable() {
int scrollOffset = -2;
int visibleChildCount = (listView.getLastVisiblePosition() - listView.getFirstVisiblePosition()) + 1; // row count visible on screen
@Override
public void run() {
listView.smoothScrollToPosition(visibleChildCount + scrollOffset + wantedPosition);
}
});
}
2013년 1월 20일 일요일
custom seekbar design
seekbar_progress_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<clip>
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:antialias="true"
android:dither="false"
android:filter="false"
android:gravity="left"
android:src="@drawable/progress_line" />
</clip>
</item>
</layer-list>
seekbar_progress.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true"
android:src="@drawable/progress_bg" />
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<gradient
android:angle="270"
android:centerColor="#80127fb1"
android:centerY="0.75"
android:endColor="#a004638f"
android:startColor="#80028ac8" />
</shape>
</clip>
</item>
<item
android:id="@android:id/progress"
android:drawable="@drawable/seekbar_progress_bg"/>
</layer-list>
<SeekBar android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="22.5dp"
android:layout_marginRight="22.5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:progress="0"
android:secondaryProgress="0"
android:progressDrawable="@drawable/seekbar_progress"
android:thumb="@drawable/ams_tool_stroke_pointer"
/>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<clip>
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:antialias="true"
android:dither="false"
android:filter="false"
android:gravity="left"
android:src="@drawable/progress_line" />
</clip>
</item>
</layer-list>
seekbar_progress.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<nine-patch
xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true"
android:src="@drawable/progress_bg" />
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<gradient
android:angle="270"
android:centerColor="#80127fb1"
android:centerY="0.75"
android:endColor="#a004638f"
android:startColor="#80028ac8" />
</shape>
</clip>
</item>
<item
android:id="@android:id/progress"
android:drawable="@drawable/seekbar_progress_bg"/>
</layer-list>
<SeekBar android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="22.5dp"
android:layout_marginRight="22.5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:progress="0"
android:secondaryProgress="0"
android:progressDrawable="@drawable/seekbar_progress"
android:thumb="@drawable/ams_tool_stroke_pointer"
/>
2013년 1월 18일 금요일
galasy nexus wifi hotspot not working on window 7
update wireless adapter driver at device manager in control panel.
2013년 1월 16일 수요일
convert array to arraylist
List myList = new ArrayList();
String[] myStringArray = new String[] {"Java", "is", "Cool"};
Collections.addAll(myList, myStringArray);
String[] myStringArray = new String[] {"Java", "is", "Cool"};
Collections.addAll(myList, myStringArray);
two things you should be careful when you are creating layout dynmically
If creating view dynamically doesn't work, inflate xml file instead.
if layoutMargin doesn't work, use padding
if layoutMargin doesn't work, use padding
2013년 1월 13일 일요일
get width and height of screen
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int screenWidth = displayMetrics.widthPixels;
int screenHeight = displayMetrics.heightPixels;
2013년 1월 12일 토요일
android image scaling, save on sdcard, read the file on sdcard
ImageView profileImage = (ImageView) findViewById(R.id.imageview);
Bitmap bitmap = AddProfileImageActivity.getInstance()
.getProfileBitmap();
// 서버 업로드용 이미지를 800*800으로 스케일링합니다.
Bitmap scaledImageForServer = Bitmap.createScaledBitmap(bitmap,
SCALED_WIDTH, SCALED_HEIGHT, true);
// 스케일된 비트맵을 파일로 저장합니다.
File sdcard = Environment.getExternalStorageDirectory();
String filePath = sdcard.getAbsolutePath() + "/test.png";
try {
FileOutputStream out = new FileOutputStream(filePath);
scaledImageForServer.compress(Bitmap.CompressFormat.PNG, 90,
out);
} catch (Exception e) {
e.printStackTrace();
}
Bitmap bitmapInSdcard = BitmapFactory.decodeFile(filePath);
profileImage.setImageBitmap(bitmapInSdcard);
2013년 1월 11일 금요일
convert inputstream to string
public static String convertStreamToString(InputStream is) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
is.close();
return sb.toString();
}
2013년 1월 10일 목요일
show soft keyboard
use the following method onCreate() or somewhere.
private void showVirturalKeyboard(){
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
InputMethodManager m = (InputMethodManager) SearchActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE);
if(m != null){
// m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
m.toggleSoftInput(0, InputMethodManager.SHOW_IMPLICIT);
}
}
}, 100);
}
2013년 1월 9일 수요일
custom checkbox background image overlay with original one
<
CheckBox
2.
android:text
=
"Custom CheckBox"
3.
android:button
=
"@drawable/checkbox_selector"
4.
android:layout_width
=
"wrap_content"
5.
android:layout_height
=
"wrap_content"
/>
2013년 1월 8일 화요일
set margin dynamically
TextView interestName = (TextView) first_item
.findViewById(R.id.interestName);
interestName.setText(checkedInterest.get(i));
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(0, 0, 10, 0);
container.addView(first_item, lp);
2013년 1월 7일 월요일
R is broken, but don't see any red mark
Delete gen folder, and you will see what is error. For example, image file name can't start with number and contain capital characters.
2013년 1월 6일 일요일
change korean font at eclipse
Go to General > Appearance > Colors and Fonts.
Choose Java Editor Text Font on the list, and change font to Verdana.
for xml files:
Window -> Preferences -> General -> Appearance -> Colors and Fonts -> Basic -> Text Fonts
Choose Java Editor Text Font on the list, and change font to Verdana.
for xml files:
Window -> Preferences -> General -> Appearance -> Colors and Fonts -> Basic -> Text Fonts
how to use svn+ssh protocol on subclipse
Go to Eclipse->Window->Preferences->Team->SVN and change the SVN Interface to SVNKit.
Then you can use svn+ssh protocol.
Then you can use svn+ssh protocol.
how to restore deleted bookmark files or folder - chrome
1. close chrome.
2. go to the below location:
C:\Users\user\AppData\Local\Google\Chrome\User Data\Default
you should change folder option to see hidden files.
3. delete bookmarks file and rename bookmarks.bak to bookmarks.
4. restart chrome.
2. go to the below location:
C:\Users\user\AppData\Local\Google\Chrome\User Data\Default
you should change folder option to see hidden files.
3. delete bookmarks file and rename bookmarks.bak to bookmarks.
4. restart chrome.
2013년 1월 5일 토요일
can not connect to hotspot - window 7
remove iptime that is connected automatically at the wireless network manager.
galaxy nexus usb recognition on eclipse, window 7
install galaxy nexus usb driver at the samsung website.
http://www.samsung.com/us/support/owners/product/SCH-I515MSAVZW
http://www.samsung.com/us/support/owners/product/SCH-I515MSAVZW
how to fix errors after importing a project by svn
change encoding(for example, utf-8) at the properties of the project.
2013년 1월 3일 목요일
2013년 1월 2일 수요일
mapView getItemsAtLocation nullPointerException
The error was arising when there was an itemizedoverlay, which had no overlayitems, on the mapview. The following code solved the error:
if(itemizedoverlayCurrent.hasItems()) overlays.add(itemizedoverlayCurrent);
if(itemizedoverlayCompleted.hasItems())overlays.add(itemizedoverlayCompleted);
if(itemizedoverlayFuture.hasItems())overlays.add(itemizedoverlayFuture);
svn- attempt to lock an already locked dir
http://www.digizol.com/2009/07/attempted-already-locked-subversion.html
android bug - textSize and gravity
If textSize and gravity(right) is set together at xml file, right end of text disappears.
피드 구독하기:
글 (Atom)