[android-developers] Re: Regarding using intents in the GridView and absolute layouts

2010-03-22 Thread NewDev
Hi Kavitha,

Thanks for the reply. Samething I tryied, i wrote like this :

grid_main.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int
position, long id) {

if(position==0){
Intent intent1 = new Intent(latest_icon_droid.this,
screen.class);
startActivity(intent1);
}
}
});

But then also, it is considering all the images are with position 0.
So when i clicked on any item, it is displaying the second screen,
which is not supposed to be displayed. :-(
Any idea, why is it like this?



On Mar 22, 4:32 pm, kavitha sunil  wrote:
> I think you can check the item that is clicked using the position param in
> the function onItemClick() and if it is the first item
> only then call start activity,. Don't call for each item click. This should
> help./
>
> On Mon, Mar 22, 2010 at 4:22 PM, NewDev  wrote:
>
> > Hi,
>
> > I am trying to write an application where I am trying to display
> > images along with the texts for the same. Images are displayed
> > properly on the grid.
>
> > Now I have one second screen, wherein On clicking only on the first
> > image, the seccond screen1 should be displayed. But now whats
> > happening is clicking on second, third, fourth and so on, images also
> > the same secocnd screen1 is displayed. I want to display the second
> > screen1 only if user clicks on first image. Could anybody please look
> > in to this and let me know where i am going wrong.
>
> > I have copied my files for your reference. I am using GridView for
> > displaying images and absolute layout for the texts for the images.
>
> > Thanks,
>
> > package com.android.latest_icon_droid;
>
> > import android.app.Activity;
> > import android.content.Context;
> > import android.os.Bundle;
> > import android.view.View;
> > import android.view.ViewGroup;
> > import android.widget.AdapterView;
> > import android.widget.BaseAdapter;
> > import android.widget.Button;
> > import android.widget.GridView;
> > import android.widget.ImageView;
> > import android.widget.TextView;
> > import android.widget.Toast;
> > import android.content.Intent;
> > import android.widget.AdapterView.OnItemClickListener;
> > import android.widget.*;
> > import android.view.LayoutInflater;
>
> > public class latest_icon_droid extends Activity {
> >    /** Called when the activity is first created. */
> >        GridView grid_main;
> >   �...@override
> >    public void onCreate(Bundle savedInstanceState) {
> >        super.onCreate(savedInstanceState);
> >        setContentView(R.layout.main1);
> >        grid_main = (GridView)findViewById(R.id.GridView01);
> >        grid_main.setAdapter(new ImageAdapter(this));
>
> >        grid_main.setOnItemClickListener(new OnItemClickListener() {
> >            public void onItemClick(AdapterView parent, View v, int
> > position, long id) {
>
> >                Intent intent1 = new Intent(latest_icon_droid.this,
> > screen.class);
> >                        startActivity(intent1);
>
> >            }
> >        });
>
> >    }
> >    public class ImageAdapter extends BaseAdapter{
> >        //Context mContext;
> >        //public static final int ACTIVITY_CREATE = 10;
> >        public ImageAdapter(Context c){
> >                mContext = c;
> >        }
> >      // �...@override
> >        public int getCount() {
> >                return mThumbIds.length;
>
> >        }
>
> >        public Object getItem(int position) {
> >           // return null;
> >                return position;
> >        }
>
> >        public long getItemId(int position) {
> >           // return 0;
> >                return position;
> >        }
>
> >  //       //@Override
> >        public View getView(int position, View convertView, ViewGroup
> > parent) {
>
> >            View v;
> >            ImageView imageView;
> >            if(convertView==null){
> >                imageView = new ImageView(mContext);
> >                imageView.setLayoutParams(new GridView.LayoutParams(45,
> > 45));
> >                imageView.setAdjustViewBounds(false);
>
> > imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
> >                imageView.setPadding(5, 5, 5, 5);
> >                LayoutInflater li = getLayoutInflater();
> >                v = li.inflate(R.layout.main, null);
> >            }
> >            els

[android-developers] Re: Regarding using intents in the GridView and absolute layouts

2010-03-22 Thread NewDev
Hi Kavitha,

Thanks for the reply. Samething I tryied, i wrote like this :

grid_main.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int
position, long id) {

if(position==0){
Intent intent1 = new Intent(latest_icon_droid.this,
screen.class);
startActivity(intent1);
}
}
});

But then also, it is considering all the images are with position 0.
So when i clicked on any item, it is displaying the second screen,
which is not supposed to be displayed. :-(
Any idea, why is it like this?



On Mar 22, 4:32 pm, kavitha sunil  wrote:
> I think you can check the item that is clicked using the position param in
> the function onItemClick() and if it is the first item
> only then call start activity,. Don't call for each item click. This should
> help./
>
> On Mon, Mar 22, 2010 at 4:22 PM, NewDev  wrote:
>
> > Hi,
>
> > I am trying to write an application where I am trying to display
> > images along with the texts for the same. Images are displayed
> > properly on the grid.
>
> > Now I have one second screen, wherein On clicking only on the first
> > image, the seccond screen1 should be displayed. But now whats
> > happening is clicking on second, third, fourth and so on, images also
> > the same secocnd screen1 is displayed. I want to display the second
> > screen1 only if user clicks on first image. Could anybody please look
> > in to this and let me know where i am going wrong.
>
> > I have copied my files for your reference. I am using GridView for
> > displaying images and absolute layout for the texts for the images.
>
> > Thanks,
>
> > package com.android.latest_icon_droid;
>
> > import android.app.Activity;
> > import android.content.Context;
> > import android.os.Bundle;
> > import android.view.View;
> > import android.view.ViewGroup;
> > import android.widget.AdapterView;
> > import android.widget.BaseAdapter;
> > import android.widget.Button;
> > import android.widget.GridView;
> > import android.widget.ImageView;
> > import android.widget.TextView;
> > import android.widget.Toast;
> > import android.content.Intent;
> > import android.widget.AdapterView.OnItemClickListener;
> > import android.widget.*;
> > import android.view.LayoutInflater;
>
> > public class latest_icon_droid extends Activity {
> >    /** Called when the activity is first created. */
> >        GridView grid_main;
> >   �...@override
> >    public void onCreate(Bundle savedInstanceState) {
> >        super.onCreate(savedInstanceState);
> >        setContentView(R.layout.main1);
> >        grid_main = (GridView)findViewById(R.id.GridView01);
> >        grid_main.setAdapter(new ImageAdapter(this));
>
> >        grid_main.setOnItemClickListener(new OnItemClickListener() {
> >            public void onItemClick(AdapterView parent, View v, int
> > position, long id) {
>
> >                Intent intent1 = new Intent(latest_icon_droid.this,
> > screen.class);
> >                        startActivity(intent1);
>
> >            }
> >        });
>
> >    }
> >    public class ImageAdapter extends BaseAdapter{
> >        //Context mContext;
> >        //public static final int ACTIVITY_CREATE = 10;
> >        public ImageAdapter(Context c){
> >                mContext = c;
> >        }
> >      // �...@override
> >        public int getCount() {
> >                return mThumbIds.length;
>
> >        }
>
> >        public Object getItem(int position) {
> >           // return null;
> >                return position;
> >        }
>
> >        public long getItemId(int position) {
> >           // return 0;
> >                return position;
> >        }
>
> >  //       //@Override
> >        public View getView(int position, View convertView, ViewGroup
> > parent) {
>
> >            View v;
> >            ImageView imageView;
> >            if(convertView==null){
> >                imageView = new ImageView(mContext);
> >                imageView.setLayoutParams(new GridView.LayoutParams(45,
> > 45));
> >                imageView.setAdjustViewBounds(false);
>
> > imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
> >                imageView.setPadding(5, 5, 5, 5);
> >                LayoutInflater li = getLayoutInflater();
> >                v = li.inflate(R.layout.main, null);
> >            }
> >            els

[android-developers] Regarding using intents in the GridView and absolute layouts

2010-03-22 Thread NewDev

Hi,

I am trying to write an application where I am trying to display
images along with the texts for the same. Images are displayed
properly on the grid.

Now I have one second screen, wherein On clicking only on the first
image, the seccond screen1 should be displayed. But now whats
happening is clicking on second, third, fourth and so on, images also
the same secocnd screen1 is displayed. I want to display the second
screen1 only if user clicks on first image. Could anybody please look
in to this and let me know where i am going wrong.

I have copied my files for your reference. I am using GridView for
displaying images and absolute layout for the texts for the images.

Thanks,




package com.android.latest_icon_droid;


import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import android.content.Intent;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.*;
import android.view.LayoutInflater;

public class latest_icon_droid extends Activity {
/** Called when the activity is first created. */
GridView grid_main;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main1);
grid_main = (GridView)findViewById(R.id.GridView01);
grid_main.setAdapter(new ImageAdapter(this));

grid_main.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int
position, long id) {


Intent intent1 = new Intent(latest_icon_droid.this,
screen.class);
startActivity(intent1);

}
});

}
public class ImageAdapter extends BaseAdapter{
//Context mContext;
//public static final int ACTIVITY_CREATE = 10;
public ImageAdapter(Context c){
mContext = c;
}
  //  @Override
public int getCount() {
return mThumbIds.length;


}

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

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

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

View v;
ImageView imageView;
if(convertView==null){
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(45,
45));
imageView.setAdjustViewBounds(false);
 
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(5, 5, 5, 5);
LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.main, null);
}
else
{
v = convertView;
//imageView = (ImageView) convertView;
}


TextView tv =
(TextView)v.findViewById(R.id.icon_text1);
ImageView iv =
(ImageView)v.findViewById(R.id.icon_image1);
iv.setImageResource(mThumbIds[0]);


TextView tv1 =
(TextView)v.findViewById(R.id.icon_text2);
ImageView iv1 =
(ImageView)v.findViewById(R.id.icon_image2);

iv1.setImageResource(mThumbIds[1]);


TextView tv2 =
(TextView)v.findViewById(R.id.icon_text3);
ImageView iv2 =
(ImageView)v.findViewById(R.id.icon_image3);

iv2.setImageResource(mThumbIds[2]);

TextView tv3 =
(TextView)v.findViewById(R.id.icon_text4);
ImageView iv3 =
(ImageView)v.findViewById(R.id.icon_image4);

iv3.setImageResource(mThumbIds[3]);

TextView tv4 =
(TextView)v.findViewById(R.id.icon_text5);
ImageView iv4 =
(ImageView)v.findViewById(R.id.icon_image5);

iv4.setImageResource(mThumbIds[4]);

TextView tv5 =
(TextView)v.findViewById(R.id.icon_text6);
ImageView iv5 =
(ImageView)v.findViewById(R.id.icon_image6);

iv5.setImageResource(mThumbIds[5]);

TextView tv6 =
(TextView)v.findViewById(R.id.icon_text7);
ImageView iv6 =
(ImageView)v.findViewById(R.id.icon_image7);

iv6.setImageResource(mThumbIds[6]);

TextView tv7 =
(TextView)v.findViewById(R.id.icon_text8);
ImageView iv7 =
(ImageView)v.findViewById(R.id.icon_image8);

iv7.setImageResource(mThumbIds[7]);

TextView tv8 =
(TextView)v.findViewById(R.id.icon_text9);

[android-developers] Re: setting an icon in the application.

2010-03-15 Thread NewDev
Sorry for the previous mail. I got it how to do it :-) Now I am able
to achieve what I wanted it :-)

Thanks again,

On Mar 11, 10:08 pm, Makas Tzavellas 
wrote:
> Sounds like you want to use a GridView, create a custom adapter that
> returns an ImageView and set OnItemClickListener to activate your
> desired behaviour.
>
> You would probably want to take a look at the API Demos that uses
> ListViews for some examples.
>
> On Mar 11, 5:55 pm, NewDev  wrote:
>
> > Hi,
>
> > I want to write an android application, that should have a homepage or
> > home screen and having many utilities. Each utility should have an
> > icon with the name. So clicking on each utility or the icon, the
> > corresponding next screen should be displayed. It should be similar to
> > the android home screen. Is there any sample application that i can
> > refer? Could anybody please let me know, how to set the icons for the
> > utilities in the homepage of my application.
>
> > Thanks in advance,
>
> > NewDev
>
>

-- 
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: setting an icon in the application.

2010-03-15 Thread NewDev
Hi,

Thanks for the reply. Yes, I used the GridView and
SetOnItemClickListener. Now am able to click on any icon and display
the details on other screen. I have a second screen or activity,
clicking on first icon it should open the second screen and clicking
on second icon it should open the third screen . But now when I click
on any icon, the same second screen is displayed. I am using intents.
So I am not getting how to achieve this? Could you please help me.

This is my code:

package com.android.grid_hello;


import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.Toast;
import android.content.Intent;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView;

public class grid_hello extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.grid_new);

GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new ImageAdapter(this));

gridview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int
position, long id) {

Intent intent1 = new
Intent(grid_hello.this,second.class);
startActivity(intent1);
}
});
}

public class ImageAdapter extends BaseAdapter {
private Context mContext;

public ImageAdapter(Context c) {
mContext = c;
}

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

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

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

// create a new ImageView for each item referenced by the
Adapter
public View getView(int position, View convertView, ViewGroup
parent) {
ImageView imageView;
if (convertView == null) {  // if it's not recycled,
initialize some attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(new
GridView.LayoutParams(85, 85));
 
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
} else {
imageView = (ImageView) convertView;
}

imageView.setImageResource(mThumbIds[position]);
return imageView;
}

// references to our images
private Integer[] mThumbIds = {
R.drawable.sample_0, R.drawable.sample_1,
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7,
};
}

}

On Mar 11, 10:08 pm, Makas Tzavellas 
wrote:
> Sounds like you want to use a GridView, create a custom adapter that
> returns an ImageView and set OnItemClickListener to activate your
> desired behaviour.
>
> You would probably want to take a look at the API Demos that uses
> ListViews for some examples.
>
> On Mar 11, 5:55 pm, NewDev  wrote:
>
> > Hi,
>
> > I want to write an android application, that should have a homepage or
> > home screen and having many utilities. Each utility should have an
> > icon with the name. So clicking on each utility or the icon, the
> > corresponding next screen should be displayed. It should be similar to
> > the android home screen. Is there any sample application that i can
> > refer? Could anybody please let me know, how to set the icons for the
> > utilities in the homepage of my application.
>
> > Thanks in advance,
>
> > NewDev
>
>

-- 
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] setting an icon in the application.

2010-03-11 Thread NewDev
Hi,

I want to write an android application, that should have a homepage or
home screen and having many utilities. Each utility should have an
icon with the name. So clicking on each utility or the icon, the
corresponding next screen should be displayed. It should be similar to
the android home screen. Is there any sample application that i can
refer? Could anybody please let me know, how to set the icons for the
utilities in the homepage of my application.

Thanks in advance,

NewDev

-- 
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: Regarding intents

2010-03-01 Thread NewDev
Hi,

Thanks for the reply. I have already added the new activity or secocnd
activity in the  AndroidManifest.xml file. I tried adding
getApplicationContext() in the intent. But still its not working. I am
herewith adding my code and also the AndroidManifest.xml file for
currency convertor. Could you please look in to the same and let me
know where am going wrong.

Thanks in advance,

Naina

1st activity:


package com.example.android.Convertor;


import android.view.View;
import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.AdapterView.OnItemClickListener;
import android.content.Intent;


public class Convertor extends ListActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setContentView(R.layout.main);
  String[] convertors =
getResources().getStringArray(R.array.converters_array);
  setListAdapter(new
ArrayAdapter(this,R.layout.list,convertors));


  ListView lv = getListView();
  lv.setTextFilterEnabled(true);

  lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View view,
int position, long id) {
Intent intent = new
Intent( getApplicationContext(),currency.class);
startActivity(intent);

}
  });
}

}


2nd activity:


package com.example.android.Convertor;

import android.view.View;
import android.widget.TextView;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.content.Intent;


public class currency extends Activity {
private EditText rate;
private EditText curr;

private TextView Exchngtext;
private TextView localcurtext;
private TextView Foreincurtext;
private TextView Foreincurval;

private Button btncalculate;
private Button btnclear;

private double exchngrt = 0;
private double loclcurr = 0;
private double forgncurr = 0;

@Override
public void onCreate(Bundle savedInstanceState) {

  setContentView(R.layout.main);

  initControls();
  setResult(RESULT_OK);
  finish();

}

private void initControls()

{

Exchngtext = (TextView)findViewById(R.id.Exchngtext);
rate = (EditText)findViewById(R.id.rate);

localcurtext =(TextView)findViewById(R.id.localcurtext);
curr = (EditText)findViewById(R.id.curr);

Foreincurtext =(TextView)findViewById(R.id.Foreincurtext);
Foreincurval = (TextView)findViewById(R.id.foreign);

btncalculate = (Button)findViewById(R.id.btncalculate);
btnclear = (Button)findViewById(R.id.btnclear);

btncalculate.setOnClickListener(new Button.OnClickListener() { public
void onClick (View v){ calculate(); }});

btnclear.setOnClickListener(new Button.OnClickListener() { public
void onClick (View v){ clear(); }});

}

private void calculate()

{

exchngrt=Double.parseDouble(rate.getText().toString());

loclcurr=Double.parseDouble(curr.getText().toString());

forgncurr=(exchngrt*loclcurr);

Foreincurval.setText(Double.toString(forgncurr));

Foreincurval.setEnabled(false);


}
private void clear()

{
rate.setText("");

curr.setText("");

Foreincurval.setText("");

}
}



AndroidManifest.xml file:



http://schemas.android.com/apk/res/android";
  package="com.example.android.Convertor"
  android:versionCode="1"
  android:versionName="1.0.0">














android:label="@string/app_name" >



 
























On Feb 27, 2:49 am, Gaunt Face  wrote:
> To launch a new activity you should be using code something like this:
>
> Intent intent = new Intent(getApplicationContext(),
> ClassNameHere.class);
> startActivity(intent);
>
> Then you also need to add your Activity to the AndroidManifest.xml
> file, if your using eclipse you can open the AndroidManifest file and
> go to:
>
> Application (Tab) > *scroll to bottom* > Add > Select Activity > Then
> copy the fields from the existing Activity
>
> This will create the xml for you, which will look a little something
> like:
>
>  activity>
>
> Hope that helps,
> Matt
>
> On Feb 25, 11:02 am, NewDev  wrote:
>
> &g

[android-developers] Regarding intents

2010-02-25 Thread NewDev
Hi,

I am new to android. I am trying to write a small application.
I have one screen(activity), on clicking it should open another screen
(activity). I am trying to use intents. But somehow my application is
not working.
I have a list of items for Tip calculator and Currency calculator
(using listView), on clicking on one item for Tip calculator, another
screen should open that has tip calculator screen. Where there are
buttons for entering the amount and percentage amount for tip.

I am writing the intent as the following in the Convertor
screen(activity):
 Intent intent = new Intent( Convertor.this,tip.class);
startActivity(intent);

Now I am not able to get what to be written for intent in the tip.
class,i.e., in another activity where the implementation for tip is
present.

Could anybody can help me?

Thanks in advance,

naina

-- 
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] How to prevent my application being closed on clicking the back button on emulator

2009-02-05 Thread NewDev

Hi,

I have an application with main view having a search button. On
clicking the search button, search results are displayed in a text
view. When I hit the back button at this view, instead of navigating
to the previous screen, application itself gets closed.  Could anybody
please let me know how to go back to previous screen.

Thanks in andvance,

Naina
--~--~-~--~~~---~--~~
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] Regarding substring function in android

2009-01-28 Thread NewDev

Hi,

Could you please tell me how the substring works in android? I will be
greatful if  you can give a sample application for the same.

Thanks,

Naina
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---