[android-developers] @Lew

2013-02-18 Thread Van Binh Nguyen
Sorry to intrude. But this is a really BAD anwsers. I'm working on the same
problem and those anwsers is rather stupid. 
Have you even bothered to checked out some of the results before you gave the
standard please google anwser ?

Never mind the results which lead me here in the first place. 
Most of the people tell me to move the video in the res/raw folder because most
of them have no idea how to load from the assets folder. 
In this case the second anwser would work. 

Of course this isn't an option if you develop an ANE for Air Applications like
me. All the other atemps seems to be based on file://android_assets and are
sketchy at best. 

Next time you want to give this anwser please think twice if it really is
appropiate.

-- 
-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[android-developers] Android spinner is not left aligned when set to wrap_content

2012-04-26 Thread Binh Nguyen
Hello experts, 

I realize that on 2.3, the spinner layout width will base on spinner item 
content, while as it fixes for widest content, and doesn't change for the 
others on 4.0. There is no problem if the spinner layout is set to 
fill_parent, but I need a wrap_content spinner... 

Do you know how to make it consistent on both system? Since it looks ugly 
when the content lengths are very different. 

Thank you. 

p/s You may see the problem in the details on stackoverflow web  

http://stackoverflow.com/questions/10329958/android-spinner-is-not-left-aligned-when-set-to-wrap-content

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Android onLayout() and AsyncTask() does not work together

2011-12-27 Thread Binh Nguyen
I finally find out the answer, the setColumnCollapsed() makes the
table layout refreshed, however we need to put it in another
AsyncTask, otherwise it will not work, strange :( .I put the latest
code here, so hope it is helpful for someone. Besides, this is just
workaround, so feel free to post your answer if any...

private class MyTask extends AsyncTaskVoid, Void, Void {

private ProgressDialog progressDialog;
protected void onPreExecute() {
progressDialog =
ProgressDialog.show(ScrollingTableActivity.this,
  , Loading. Please wait...,
true);
}
@Override
protected Void doInBackground(Void... reportTypes) {
for (int i = 0; i  500; i++) {
System.out.println(i);
}
return null;
}
@Override
protected void onPostExecute(Void result) {
progressDialog.dismiss();
appendRows(tableHeader, tableBody, tableData);

new My1Task().execute();
}
}

private class My1Task extends AsyncTaskVoid, Void, Void {

@Override
protected Void doInBackground(Void... reportTypes) {
return null;
}

@Override
protected void onPostExecute(Void result) {
tableHeader.setColumnCollapsed(0, false);
tableBody.setColumnCollapsed(0, false);
}
}

On Dec 27, 2:03 pm, Zsolt Vasvari zvasv...@gmail.com wrote:
 I'd pepper a bunch of Log.v() calls throught the code and see where it
 goes wrong.

 On Dec 27, 9:59 am, Binh Nguyen nguyenthanhbinh1...@gmail.com wrote:







  Yeah, I got it from AsyncTask usage, so the onLayout() should work,
  right. btw, I attach some screenshots on Stack Overflow site, so you
  can see the problem 
  clearly:http://stackoverflow.com/questions/8613465/android-onlayout-and-async...

  Binh Nguyen
  On Dec 27, 5:35 am, Romain Guy romain...@android.com wrote:

   onPostExecute() is called on the UI thread.

   On Mon, Dec 26, 2011 at 1:20 AM, Binh Nguyen

   nguyenthanhbinh1...@gmail.com wrote:
Hi experts,

I need a scrollable table with fixed header, so I followed this great
blog (http://blog.stylingandroid.com/archives/432) and everything is
fine.

The idea is using one table for header, one table for content added in
scrollview, both of them are in a customized LinearLayout. In
customized LinearLayout, we will overwrite the onLayout() to get the
max width of each row and set width for each row of both header and
content table.

Here is the activity and its layout:

package com.stylingandroid.ScrollingTable;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TableLayout;
import android.widget.TableRow;

public class ScrollingTable extends LinearLayout
{
   public ScrollingTable( Context context )
   {
       super( context );
   }
public ScrollingTable( Context context, AttributeSet attrs )
{
   super( context, attrs );
}

@Override
protected void onLayout( boolean changed, int l, int t, int r, int b )
{
   super.onLayout( changed, l, t, r, b );

   TableLayout header = (TableLayout)
findViewById( R.id.HeaderTable );
   TableLayout body = (TableLayout) findViewById( R.id.BodyTable );

   if (body.getChildCount()  0 ) {
       TableRow bodyRow = (TableRow) body.getChildAt(0);
       TableRow headerRow = (TableRow) header.getChildAt(0);

       for ( int cellnum = 0; cellnum  bodyRow.getChildCount();
cellnum++ ){
           View bodyCell = bodyRow.getChildAt(cellnum);
           View headerCell = headerRow.getChildAt(cellnum);
           int bodyWidth = bodyCell.getWidth();
           int headerWidth = headerCell.getWidth();
           int max = Math.max(bodyWidth, headerWidth);
           TableRow.LayoutParams bodyParams =
(TableRow.LayoutParams)bodyCell.getLayoutParams();
           bodyParams.width = max;
           TableRow.LayoutParams headerParams =
(TableRow.LayoutParams)headerCell.getLayoutParams();
           headerParams.width = max;
       }
   }
}
}

main.xml
===

 ?xml version=1.0 encoding=utf-8?
LinearLayout xmlns:android=http://schemas.android.com/apk/res/
android
   android:orientation=vertical
   android:layout_width=fill_parent
   android:layout_height=fill_parent

   com.stylingandroid.ScrollingTable.ScrollingTable
       android:layout_width=match_parent
       android:orientation=vertical
       android:layout_height=match_parent

       TableLayout
           android:layout_height=wrap_content
           android:layout_width=match_parent
           android:id=@+id/HeaderTable
       /TableLayout

[android-developers] Re: Android onLayout() and AsyncTask() does not work together

2011-12-26 Thread Binh Nguyen
Yeah, I got it from AsyncTask usage, so the onLayout() should work,
right. btw, I attach some screenshots on Stack Overflow site, so you
can see the problem clearly:
http://stackoverflow.com/questions/8613465/android-onlayout-and-asynctask-does-not-work-together

Binh Nguyen
On Dec 27, 5:35 am, Romain Guy romain...@android.com wrote:
 onPostExecute() is called on the UI thread.

 On Mon, Dec 26, 2011 at 1:20 AM, Binh Nguyen









 nguyenthanhbinh1...@gmail.com wrote:
  Hi experts,

  I need a scrollable table with fixed header, so I followed this great
  blog (http://blog.stylingandroid.com/archives/432) and everything is
  fine.

  The idea is using one table for header, one table for content added in
  scrollview, both of them are in a customized LinearLayout. In
  customized LinearLayout, we will overwrite the onLayout() to get the
  max width of each row and set width for each row of both header and
  content table.

  Here is the activity and its layout:

  package com.stylingandroid.ScrollingTable;

  import android.content.Context;
  import android.util.AttributeSet;
  import android.view.View;
  import android.widget.LinearLayout;
  import android.widget.TableLayout;
  import android.widget.TableRow;

  public class ScrollingTable extends LinearLayout
  {
     public ScrollingTable( Context context )
     {
         super( context );
     }
  public ScrollingTable( Context context, AttributeSet attrs )
  {
     super( context, attrs );
  }

  @Override
  protected void onLayout( boolean changed, int l, int t, int r, int b )
  {
     super.onLayout( changed, l, t, r, b );

     TableLayout header = (TableLayout)
  findViewById( R.id.HeaderTable );
     TableLayout body = (TableLayout) findViewById( R.id.BodyTable );

     if (body.getChildCount()  0 ) {
         TableRow bodyRow = (TableRow) body.getChildAt(0);
         TableRow headerRow = (TableRow) header.getChildAt(0);

         for ( int cellnum = 0; cellnum  bodyRow.getChildCount();
  cellnum++ ){
             View bodyCell = bodyRow.getChildAt(cellnum);
             View headerCell = headerRow.getChildAt(cellnum);
             int bodyWidth = bodyCell.getWidth();
             int headerWidth = headerCell.getWidth();
             int max = Math.max(bodyWidth, headerWidth);
             TableRow.LayoutParams bodyParams =
  (TableRow.LayoutParams)bodyCell.getLayoutParams();
             bodyParams.width = max;
             TableRow.LayoutParams headerParams =
  (TableRow.LayoutParams)headerCell.getLayoutParams();
             headerParams.width = max;
         }
     }
  }
  }

  main.xml
  ===

   ?xml version=1.0 encoding=utf-8?
  LinearLayout xmlns:android=http://schemas.android.com/apk/res/
  android
     android:orientation=vertical
     android:layout_width=fill_parent
     android:layout_height=fill_parent

     com.stylingandroid.ScrollingTable.ScrollingTable
         android:layout_width=match_parent
         android:orientation=vertical
         android:layout_height=match_parent

         TableLayout
             android:layout_height=wrap_content
             android:layout_width=match_parent
             android:id=@+id/HeaderTable
         /TableLayout

         ScrollView
             android:layout_width=match_parent
             android:layout_height=wrap_content

             TableLayout
                 android:layout_height=wrap_content
                 android:layout_width=match_parent
                 android:id=@+id/BodyTable
             /TableLayout

         /ScrollView

     /com.stylingandroid.ScrollingTable.ScrollingTable

  /LinearLayout

  Main activity
  ==

  package com.stylingandroid.ScrollingTable;

  import android.app.Activity;
  import android.app.ProgressDialog;
  import android.graphics.Color;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.widget.TableLayout;
  import android.widget.TableRow;

     import android.widget.TextView;

     public class ScrollingTableActivity extends Activity
     {
         private String[][] tableData = {
                 {header111, header2,header3,header4},
                 {column1, column1,column1,column1},
                 {column1, column1,column1,column1},
                 {column1, column1,column1,column1},

     {column1, column1,

  column1,column1},
                 {column1, column1,column1,column1},
                 {column1, column1,column1,column1},
                 {column1, column1,column1,column1},
                 {column1, column1,column1,column1},
                 {column1, column1,column1,column1},
                 {column1, column1,column1,column1},
                 {column1, column1,column1,column1},
                 {column1, column1,column1,column1}
         };
         /** Called when the activity is first created. */
         @Override
         public void onCreate( Bundle savedInstanceState )
         {
             super.onCreate( savedInstanceState );
             setContentView

[android-developers] Android onLayout() and AsyncTask() does not work together

2011-12-25 Thread Binh Nguyen
]);
c.setPadding(3, 3, 3, 3);
if (i == 0) {
c.setTextColor(Color.BLACK);
}
row1.addView(c);
}

if (i == 0) {
row1.setBackgroundColor(Color.LTGRAY);
tableHeader.addView(row1, new TableLayout.LayoutParams());
} else {
tableContent.addView(row1, new
TableLayout.LayoutParams());
}
}
}


The above code work perfectly, however, when I use AnysnTask to get
data from server and add data to table later, the onLayout() in my
custom view doesn't work anymore. I simulate getting data by log out
some number:

public void onCreate( Bundle savedInstanceState )
{
super.onCreate( savedInstanceState );
setContentView( R.layout.main );

new MyTask().execute();
}

private class MyTask extends AsyncTaskVoid, Void, Void {

private ProgressDialog progressDialog;
protected void onPreExecute() {
progressDialog =
ProgressDialog.show(ScrollingTableActivity.this,
  , Loading. Please wait...,
true);
}
@Override
protected Void doInBackground(Void... reportTypes) {
for (int i = 0; i  500; i++) {
System.out.println(i);
}
return null;
}
@Override
protected void onPostExecute(Void result) {
progressDialog.dismiss();
TableLayout tableHeader =
(TableLayout)findViewById(R.id.HeaderTable);
TableLayout tableBody =
(TableLayout)findViewById(R.id.BodyTable);

appendRows(tableHeader, tableBody, tableData);
}

}

So the onLayout() only work when I call appendRows() from main UI
thread by putting it in onCreate() method. If I call from another
thread (in onPostExecute() of AsyncTask), the onLayout() is called (I
checked it by create some logs) but it doesn't effect to the GUI. I
tried with invalidate(), forceLayout(), requestLayout() but doesn't
change anything.

I think we need to call a method to make the GUI refresh but don't
know what it is, I have searched and tried a lot of ways in 2 days but
got nothing, so it will be very appreciated if you can give any idea
about this.

Many thanks,
Binh Nguyen

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Help me about publish fee

2010-12-13 Thread binh nguyen
I want to develop on Android Applications, but I dont know publish fee
(sign + test +...). Can anyone help me ?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] BaseAdapter doesn't return position correctly

2009-12-17 Thread Binh Nguyen
I custom the BaseAdapter to show image array with full-screen mode. I
want the user can flick the images so I use the gallery class.When a
image displays on the screen, a correlative sentence should be showed
as well.

The issue is the position param in getView function jump abnormally,
especially when I flick into more one picture at a time. Therefore the
string is showed incorrectly, I don't know why the image still
displays normally.

Here is my code:

public class ImageAdapter extends BaseAdapter {
int mGalleryItemBackground;
private Context mContext;
private Integer[] mImageIds = {
R.drawable.number1,
R.drawable.number2,
R.drawable.number3,
R.drawable.number4,
R.drawable.number5,
R.drawable.number6,
R.drawable.number7,
R.drawable.number8,
R.drawable.number9,
R.drawable.number10
};
private String[] captions = {
1. How ,
2. How ,
3. How ,
4. How ,
5. How ,
6. How ,
7. What ,
8. How ,
9. How ,
10. What 
};


public ImageAdapter(Context c) {
mContext = c;
TypedArray a = c.obtainStyledAttributes(Gallery1);
mGalleryItemBackground = a.getResourceId(
Gallery1_android_galleryItemBackground, 0);
a.recycle();
}

public int getCount() {
return mImageIds.length;
}

public Object getItem(int position) {
return position;
}

public long getItemId(int position) {
return position;
}

public View getView(int position, View convertView, ViewGroup
parent) {

ImageView i = new ImageView(mContext);
Log.i(position, == + position);
i.setImageResource(mImageIds[position]);
textview.setText(captions[position]);
i.setLayoutParams(new Gallery.LayoutParams
(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
i.setScaleType(ImageView.ScaleType.FIT_CENTER);
i.setBackgroundResource(mGalleryItemBackground);
return i;
}

}

=

Please let me know if you have any idea.
Thanks in advance.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Showing application version

2009-12-04 Thread Binh Nguyen
I follow the code below but it always show 'getPackageInfo() is
undefined' error, anyone knows the reason.

Thanks in advance

On Oct 26, 9:19 pm, Greivin Lopez greivin.lo...@gmail.com wrote:
 Or just use the following code snippet:

 /**
  * Gets the softwareversionandversionname for this application
  */
  private void getSoftwareVersion() {
       try {
             PackageInfo pi = getPackageManager().getPackageInfo
 (getPackageName(), 0);
             // Store the softwareversioncode andversionname
 somewhere..
             Global.softwareVersion = pi.versionCode;
             Global.softwareVersionText =
 pi.versionName;
         } catch (PackageManager.NameNotFoundException e) {
             Log.e(TAG, Package name not found, e);
         };
     }

 Good luck with your Android programming! :)

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en