블로그 이미지
JoyfulLife

공지사항

최근에 받은 트랙백

글 보관함

calendar

          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            

Using Arraylist with Object

2010.11.08 23:47 | Posted by JoyfulLife
I'm not good at C++.  I'm a Java developer. Java is easier than C++.

Here is what I had problem yesterday.

I made class RecommendItem. And I wanted this to add ArrayList.

When I use Java, that's very easy.

clase RecommendItem
{
}

ArrayList<RecommendItem> a=new ArrayList<RecommendList>();
a.add(new RecommendItem);

that's it.

but C++..

class RecommendItem : public Object
{
}
.h, and *.cpp.

ArrayList *t=new ArrayList;
t->Consturct();

t->Add(*(new RecommendItem()));


I don't like Pointer. I didn't wrote public Object. So t->Add(*(new Recommend())).. this line was wrong.. because in bada, the class that have to be Add() must inherite Object.

If you want to ArrayList , Don't forget to inherit Object.

Don't bet on bada will be successed . You should load up on C++. Don't egg on your friend to study Bada.

Bada have to be upgrade many times.

신고

'Bada' 카테고리의 다른 글

Using Arraylist with Object  (0) 2010.11.08
To get all contact in the Bada  (0) 2010.10.26
bada 에서 핸드폰 전화번호 알아내기.  (0) 2010.10.25
바다에서 post 사용하기  (0) 2010.10.16
Bada 1.1.0b1 공개  (0) 2010.10.12
Bada 에서 Json 사용  (0) 2010.10.03

Drag and drop in Android

2010.11.05 16:01 | Posted by JoyfulLife

There is a source that someone made using music source in Android platform.

http://www.kandroid.org/board/board.php?board=sourcecode&command=body&no=34

But it's not perfect.

abd



You can see this when you run the source.





When you click the 1's item, and moving to bottom, you 're going to notice the problem.
Did you see the problem?
I don't like 1's item between 0's and 2's.
I wanted 2's item to be bottom.

So, I looked the source. At the first time, I think the source maker made a mistake. So I tried to find source error.
But source was perfect. I compared this source with Android music source, There were no problem.








finally, I got the problem.
problem was gravity.

when you see DndSampleActivity.java
there are

mAdapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, data);

in OnCreate().

R.layout.simple_list_item_1 is

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:gravity="center_vertical"
    android:paddingLeft="6dip"
    android:minHeight="?android:attr/listPreferredItemHeight"
/>


android:gravity="center_vertical" is not good match at this point.

center_vertical make text to be center. I want text to be bottom.

So I make the row.xml in the layout.

R.layout.row.xml is

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:paddingLeft="6dip"
    android:minHeight="?android:attr/listPreferredItemHeight" android:gravity="bottom|center_vertical"/>

and 
mAdapter = new ArrayAdapter<String>(this,
                R.layout.row, data);

I added bottom to the gravity.



Now, you can see the item that is right place.

신고
물론 자바이다.

URL url = null;
URLConnection urlConnection;
        try {
            urlConnection = url.openConnection();
            urlConnection.connect();
            List urlvalues = urlConnection.getHeaderFields().get("content-length");
            if (urlvalues != null && !urlvalues.isEmpty()) {
                String sLength = (String) urlvalues.get(0);
                Log.i("Test","slength="+sLength);
            }

이런 식으로 하면 된다.
urlConnection 의 헤더를 살펴보면 된다. 처음에는 content-Length 로 해서 못 받아왔는데.. 지금은 디버그로 한방에 찾았다.

실력은 예전에 비해 늘어난거 같다. 모 http 에 대해서 공부를 해서 그런거 같다.

신고

'안드로이드어플리케이션' 카테고리의 다른 글

How to get File size using HTTP protocol  (0) 2010.10.28
Korean Bible Viewer  (28) 2010.06.23

티스토리 툴바