Reputation:
please i am making that changes picture for the url and i have a problem..... the image does display what i want is not the picture should change depending ont the list item i click..... it work when i use the r.drawable.image....... but not working when i try to use the getimage url and it is not working.... i used the universal-image-loader-1.6.2.jar and it iis giving me errors...... this is my code.......... and NOTE THAT artp is the url of a picture that i saved in the databse and it is coming from anoder class...
this is my code
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class Music extends Activity{
TextView name,song,album,about;
String nam,son,albu,abou;
ImageView picc;
Button listen, download;
public int newInt;
MainActivity maa = new MainActivity();
Bundle extras = getIntent().getExtras();
String artp = extras.getString("artp");
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stu
super.onCreate(savedInstanceState);
setContentView(R.layout.music);
name= (TextView) findViewById(R.id.name);
song= (TextView) findViewById(R.id.song);
album=(TextView) findViewById(R.id.album);
about=(TextView) findViewById(R.id.about);
picc=(ImageView) findViewById(R.id.picc);
listen=(Button) findViewById(R.id.listen);
download=(Button) findViewById(R.id.download);
settext();
}
private void settext() {
Bundle extras = getIntent().getExtras();
newInt= extras.getInt("man");
String abt = extras.getString("abt");
String son = extras.getString("son");
String alb = extras.getString("alb");
String art = extras.getString("art");
String abt2 = extras.getString("abt2");
String son2 = extras.getString("son2");
String alb2 = extras.getString("alb2");
String art2 = extras.getString("art2");
if(newInt==0){
name.setText(art);
song.setText(son);
album.setText(alb);
about.setText(abt);
listen.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent ner = new Intent(Intent.ACTION_VIEW, Uri.parse("http://media.takserver.in/Hamid/Music/1391/11/25/Imagine%20Dragons%20-%20Night%20Visions/Imagine%20Dragons%20-%20Night%20Visions/004-imagine_dragons-demons.mp3"));
startActivity(ner);
}
});
download.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent ner = new Intent(Intent.ACTION_VIEW, Uri.parse("http://media.takserver.in/Hamid/Music/1391/11/25/Imagine%20Dragons%20-%20Night%20Visions/Imagine%20Dragons%20-%20Night%20Visions/004-imagine_dragons-demons.mp3"));
startActivity(ner);
}
});
// Get singletone instance of ImageLoader
ImageLoader imageLoader = ImageLoader.getInstance();
// Initialize ImageLoader with configuration. Do it once.
imageLoader.init(ImageLoaderConfiguration.createDefault(this));
// Load and display image asynchronously
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.ic_launcher) //this is the image that will be displayed if download fails
.cacheInMemory()
.cacheOnDisc()
.build();
imageLoader.displayImage(artp, picc, options);
}
}
}
Upvotes: 2
Views: 641
Reputation: 3615
Picasso allows for hassle-free image loading in your application—often in one line of code!
Picasso.with(context).load("http://i.imgur.com/DvpvklR.png").into(imageView);
Many common pitfalls of image loading on Android are handled automatically by Picasso
Upvotes: 1
Reputation: 18933
First you can't perform this operation before onCreate()
method.
MainActivity maa = new MainActivity();
Bundle extras = getIntent().getExtras();
String artp = extras.getString("artp");
Also you can't instantiate your Activity. So just move these line in onCreate()
method.
Bundle extras = getIntent().getExtras();
String artp = extras.getString("artp");
Also make String artp
global variable and after that on onCreate()
retrieve as
Bundle extras = getIntent().getExtras();
artp = extras.getString("artp");
Upvotes: 1