Någon som kan kolla på min kod?
Den är kort, och den fungerar inte. :-/
Jag försökte hitta lite tutorials för imagegetter och fromhtml men jag tror inte jag fattat riktigt.
Kod:
package com.lofgren.minapp;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.Html;
import android.text.Html.ImageGetter;
import android.text.Spanned;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class ShowDetails extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.details); }
public void onWindowFocusChanged(boolean hasWindowFocus) {
TextView detailsTitle = (TextView)findViewById(R.id.detailstitle);
TextView detailsDescription = (TextView)findViewById(R.id.detailsdescription);
TextView detailsPubdate = (TextView)findViewById(R.id.detailspubdate);
TextView detailsLink = (TextView)findViewById(R.id.detailslink);
Bundle bundle = this.getIntent().getExtras();
detailsTitle.setText(bundle.getString("keyTitle"));
// ####Koden nedan är det som är vajsing ############
detailsDescription.setText(Html.fromHtml(bundle.getString("keyDescription"), new ImageGetter() {
@Override
public Drawable getDrawable(String source) {
String path = "/sdcard/" + source;
Drawable bmp = Drawable.createFromPath(path);
bmp.setBounds(0, 0, bmp.getIntrinsicWidth(), bmp.getIntrinsicHeight());
return bmp;
}
}, null));
// ##### Allt nedanför fungerar. #####
detailsPubdate.setText(bundle.getString("keyPubdate"));
detailsLink.setText(bundle.getString("keyLink"));
Button backbutton = (Button) findViewById(R.id.backbutton);
backbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
finish();
}
});
}
}