в БД Sqlite храниться текст и ссылки (URL) на изображения в сети.
Читал многие варианты предлагаемые в просторах инета : про хранение в самой БД в виде blob; и про picaso.
Но я хочу чтобы в БД хранился адрес URL на картинку а сама картинка в сети.
Готовый проект с БД нашел в сети. Какой-то добрый человек выложил. Спасибо ему!
дальше чуть по правил что смог. и все так и не выходит чтобы изображение отображалось.
Что не так?
во вложении проект.
косяк думаю где то тут.
Код: Выделить всё
import android.annotation.TargetApi;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.ImageView;
import java.util.Locale;
public class DictionaryActivity extends ActionBarActivity {
private TextView wordMeaning;
// добавил вот эту строку ниже.
private TextView photo;
private ImageView photo1;
private TextToSpeech convertToSpeech;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dictionary);
Intent intent = getIntent();
Bundle bundle = intent.getExtras();
int dictionaryId = bundle.getInt("DICTIONARY_ID");
int id = dictionaryId + 1;
TextView word = (TextView)findViewById(R.id.word);
wordMeaning = (TextView)findViewById(R.id.dictionary);
// добавил вот эту строки ниже.
photo = (TextView)findViewById(R.id.dictionary1);
photo1 = (ImageView)findViewById(R.id.dictionary2);
Button textToSpeech = (Button)findViewById(R.id.button);
DbBackend dbBackend = new DbBackend(DictionaryActivity.this);
QuizObject allQuizQuestions = dbBackend.getQuizById(id);
word.setText(allQuizQuestions.getWord());
wordMeaning.setText(allQuizQuestions.getDefinition());
// добавил вот эту строки ниже.
photo.setText(allQuizQuestions.getPhoto());
// тут явно чтото я не так написал. а вот что не могу разобрать пока что.
[color=#FF0040] photo1.setImageURI(Uri.parse(""));[/color]
textToSpeech.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String convertTextToSpeech = wordMeaning.getText().toString();
convertToSpeech = new TextToSpeech(getApplicationContext(), new TextToSpeech.OnInitListener() {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onInit(int status) {
if(status != TextToSpeech.ERROR){
convertToSpeech.setLanguage(Locale.US);
convertToSpeech.speak(convertTextToSpeech, TextToSpeech.QUEUE_FLUSH, null, null);
}
}
});
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_dictionary, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onPause() {
if(convertToSpeech != null){
convertToSpeech.stop();
convertToSpeech.shutdown();
}
super.onPause();
}
}