I am new to android. I am using Intent to show full screen image and swipe between the images. The code is like:
(I am using grid to display images, Once I click on Image in grid I am calling intent)
Gridview_sponsor = (GridView) findViewById(R.id.gridViewSponsor);
Gridview_sponsor
.setOnItemLongClickListener(new OnItemLongClickListener() {
public boolean onItemLongClick(AdapterView<?> arg0,
View arg1, int pos, long id) {
AlertDialog diaBox = AskOption(imagesName.get(pos)
.toString());
diaBox.show();
return true;
}
});
Gridview_sponsor.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long arg3) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(
Uri.parse("file://" + imagesName.get(position)),
"image/*");
startActivity(intent);
}
});
Previously it was working properly. But after uninstalling existing app it stop swapping.
In above code imagesName.get(position) contains the image path which I am assigning to ACTION_VIEW intent. But it is only showing the image in full screen and zoom in ,zoom out functionality is working fine.But the images are not getting swipe from that folder
Related
I am getting a JSON data which contains for example the news headline and the url address for the news in the actual website.
I am using ListView to display the headlines. But how do I make it in such a way that when each item is clicked it will open up the corresponding link in the Android browser. Below is my code snippet:
String title = c.getString(TAG_TITLE);
String link = c.getString(TAG_ALTERNATE);
list.add(title);
final StableArrayAdapter adapter = new StableArrayAdapter(this,
android.R.layout.simple_list_item_1, list);
listview.setAdapter(adapter);
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
startActivity(browserIntent);
}
});
The issue is when I click on the item it loads up the page from only 1 link. All items when clicked go to the same page.
Any idea where I have gone wrong? How do I make it in such a way that each item when clicked will go to it's respective link?
put corresponding link in a list at the time of parsing json.
List<String> listLink= new ArrayList<String>
listLink.add(link);
set crosponding link of title when creation Intent in OnItemClickListner of ListView. i.e.
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(listLink.get(arg2)));
startActivity(browserIntent);
}
});
i think you should make the title and link into a javabean,so when you click a item ,you can use the javabean and get the link,at last ,you will linked to different websites.
lv.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
Toast.makeText(getBaseContext(),s[arg2], Toast.LENGTH_LONG).show();
if(s[arg2].equals("Facebook"))
{
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.facebook.com")));
}
else if(s[arg2].equals("Twitter"))
{
startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.twitter.com")));
}
else
{
//Message here
}
}
});
May be
Intent browserIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(adapter.getItem(arg2).toString());
startActivity(browserIntent);
or Something like this.
However, for understanding :
You get a 1 link because in 2 cases you getting a 1 value. It's simple. Enjoy!:)
Ok got it. I declared another list and get the link from that list. Below is the code:
list.add(title);
linklist.add(link);
final StableArrayAdapter adapter = new StableArrayAdapter(this,android.R.layout.simple_list_item_1, list);
listview.setAdapter(adapter);
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(linklist.get(arg2).toString()));
startActivity(browserIntent);
}
});
I am a android developer and i want to develop an application. In this app, i want to show a gallery image slider.In this slider ,the focus able image see should large and place to middle point and other image see should be small to same bellow picture.
I also try the below code .It is also show the large focus able image but not same .
gallery.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
Log.d("position", "" + arg3);
ProductByCategoryData productByCategoryData = AllProductByCategoryData
.getAllProductByCategoryData(arg2);
Constant.producdata = productByCategoryData;
Intent i = new Intent(ModeltypeActivity.this, OrderDetailInformation.class);
startActivity(i);
}
});
gallery.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
#Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
if (lastSelectedView != null)
{
lastSelectedView.setLayoutParams(new Gallery.LayoutParams(
lowLavelWidth, lowtLavelheight));// 150, 200//100, 150
}
arg1.setLayoutParams(new Gallery.LayoutParams(heighLavelWidth, heightLavelheight));// 220,
// 315//150, 200
lastSelectedView = arg1;
int vectorPosition = arg2;
ProductByCategoryData product = AllProductByCategoryData
.getAllProductByCategoryData(vectorPosition);
product_name.setText(product.getProduct_name());
}
#Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
Now how to show the gallery slider image same to above image.please help to me.It is Possibel ?
By using the content provider I have inflated SMS in Inbox List View of my application. Now On item Click I want to show SMS text in another activity. I've implemented custom list view. Now I am not getting how to pick each single list item and show in new activity on click. In a Stack flow answer somebody suggested this:
#Override
protected void onListItemClick(ListView l, View v, int position, long id) {
Uri mailUri = ContentUris.withAppendedId(getIntent().getData(), id);
startActivity(new Intent(Intent.ACTION_VIEW, mailUri));
}
If this code is correct then how I will configure next activity to act upon this ACTION_VIEW?
list.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1,int pos, long arg3) {
Intent i= new Intent(currentClass.this,secondActivity.class);
i.putExtra("string",Yourlist.get(pos).sms);
startActivity(i);
finish();
}
});
& on Another Activity You can receive through this:-
String msg=getIntent().getExtras().getString("string");
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
switch(position)
{ case 0:
Intent firstIntent = new Intent(AndroidListViewActivity.this, SingleListItem.class);
startActivity(firstIntent);
break;
case 1:
Intent secondintent = new Intent(AndroidListViewActivity.this,jokes.class);
startActivity(secondintent);
break;
i am creating an application with a listview and what i want to happen is when you choose an item from the listview the application will automatically move you to the next screen. Is this possible to do?
Thanks
have a look at setOnClickListener() of your ListView. then you can use startActivity() to skip to the next screen/activity.
ListView lv = (ListView)findeViewById(...);
lv.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> av, View v, int index, long arg3) {
// index = the index of the clicked element in the listview
// create an intent and add index to its data
startActivity(intent);
}
});
Have a look at onItemClick and use startActivity() to bring up a new screen.
For listening the list item click events you need to override onItemClickListener method .
See here :
mylist.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
Intent intent=new Intent(getApplicationContext(),NextActivity.class);
//If you want to pass parameters/values to NextActivity use putExtra
intent.putExtra("my_data","my_values");
startActivity(intent);
}
});
try this code..it will helpful for u..
"list.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
Intent intent=new Intent();
intent.setClass(nextScreen.this,profile_details.class);
intent.putExtra("profile", mArray.get(mPosition));
startActivityForResult(intent,0);
}
});"
use this code.....
I created a ListView with bunch of items, but I am not actually sure how to implement a listener on a specific items. Please help me! I would realy applreacte it a lot.
I tried to use this code, but when I click on any items, it will only bring me to the same Activity.
list.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> arg0, View arg1, int position,long id)
{
Intent i = new Intent(MainActivity.this, Activity2.class);
startActivity(i);
}
});
But if I use this code with if statement, nothing is happening:
list.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> arg0, View arg1, int position,long id)
{
if(list.getItemAtPosition(position).equals(mStrings[0]))
{
Intent i = new Intent(MainActivity.this, Activity2.class);
startActivity(i);
}
}
});
You could base your condition on position itself:
if (position == 0) {
... start activity ...
}
Maybe set different listeners in the getView method of the adapter>