Oh ok, ich probiers mal mit dem ganzen Quelltext, vllt sind Ausschnitte nicht so gut geeignet dafür. Wenn du es dann immer noch nicht verstehst, kläre ich dich auf :-). Problem vom Post #44 besteht noch immer
Das ist die MainActivity.java
Java
package com.gerritschroeer.entwurf3;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast;
import java.io.IOException;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity {
DatabaseHelper myDB;
private RecyclerView mRecylcerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManger;
private TextView textView;
public String TextTransmitter = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myDB = new DatabaseHelper(this);
try {
myDB.createDataBase();
} catch (IOException e) {
e.printStackTrace();
}
try {
myDB.openDataBase();
}catch(SQLException sqle){
throw sqle;
}
textView = (TextView) findViewById(R.id.textViewStory);
mRecylcerView = (RecyclerView) findViewById(R.id.theRecyclerView);
mRecylcerView.setHasFixedSize(true);
mLayoutManger = new LinearLayoutManager(this);
mRecylcerView.setLayoutManager(mLayoutManger);
mAdapter = new RVAdapter(getDataSet());
mRecylcerView.setAdapter(mAdapter);
StoryLogik();
}
@Override
protected void onResume(){
super.onResume();
}
public void StoryLogik(){
//DATENBANK ABFRAGEN DER JEWEILIGEN TABELLEN
String selectQueryTEXT = "SELECT TEXT FROM story_table";
String selectQueryIDL_ = "SELECT ID_STORYTEXT_LEFT FROM decisions_table";
String selectQueryIDR_ = "SELECT ID_STORYTEXT_RIGHT FROM decisions_table";
//DATENBANK ÖFFNEN
SQLiteDatabase db = myDB.getReadableDatabase();
// CURSOR INIT UND AN ANFANG DER TABELLE SETZEN
Cursor cursorTEXT = db.rawQuery(selectQueryTEXT, null);
Cursor cursorIDL = db.rawQuery(selectQueryIDL_, null);
Cursor cursorIDR = db.rawQuery(selectQueryIDR_, null);
cursorTEXT.moveToFirst();
cursorIDL.moveToFirst();
cursorIDR.moveToFirst();
String str = "";
str = cursorTEXT.getString(cursorTEXT.getColumnIndex("TEXT"));
TextTransmitter = str;
getDataSet();
cursorTEXT.moveToNext();
str = cursorTEXT.getString(cursorTEXT.getColumnIndex("TEXT"));
TextTransmitter = str;
getDataSet();
}
private ArrayList<DataObject> getDataSet() {
//Toast.makeText(this,TextTransmitter,Toast.LENGTH_SHORT).show();
//String[] test = {"Test1", "Test2", "Test3", "Test4"};
String schtring = "";
schtring = TextTransmitter;
ArrayList results = new ArrayList<DataObject>();
DataObject obj = new DataObject(schtring);
results.add(obj);
return results;
}
}
Alles anzeigen