Navigate to the next entry in sqlite database - android
I am developing an app and I have the following files:
MainActivity.java - to populate a listview
//...
mDBHelper = new DatabaseHelperArchitects(this);
File database = getApplicationContext().getDatabasePath(DatabaseHelperArchitects.DBNAME);
AZModelArchitectsList = mDBHelper.getListWord("");
word_adapter = new Architects_WordAdapter();
word_adapter.setData(AZModelArchitectsList);
rvWord.setAdapter(word_adapter);
//...
DatabaseHelperArchitects.java - to openDatabase, query the data and add data in a model list, Upgrade database method, Close database method, etc.
public List<AZModelArchitects> getListWord(String wordSearch) {
AZModelArchitects dictionaryModel = null;
List<AZModelArchitects> dictionaryModelList = new ArrayList<>();
openDatabase();
String args = {"%" + wordSearch + "%", "%" + wordSearch + "%"};
cursor = mDatabase.rawQuery("Select * From architects_az Where architect_name Like ? OR architect_period Like ?", args);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
dictionaryModel = new AZModelArchitects(
cursor.getString(1),
cursor.getString(2),
cursor.getString(3),
cursor.getString(4),
cursor.getString(5)
);
dictionaryModelList.add(dictionaryModel);
cursor.moveToNext();
}
cursor.close();
closeDatabase();
return dictionaryModelList;
}
AZModelArchitects - the model
public class AZModelArchitects {
private String id;
private String architect_image;
private String architect_description;
private String architect_period;
private String architect_source;
public AZModelArchitects(String id, String architect_image, String architect_description, String architect_period, String architect_source) {
this.id = id;
this.architect_image = architect_image;
this.architect_description = architect_description;
this.architect_period = architect_period;
this.architect_source = architect_source;
}
public String getId() {
return id;
}
public String getArchitect_image() {
return architect_image;
}
public String getArchitect_description() {
return architect_description;
}
public String getArchitect_period() {
return architect_period;
}
public String getArchitect_source() {
return architect_source;
}
public void setId(String id) {
this.id = id;
}
public void setArchitect_image(String architect_image) {
this.architect_image = architect_image;
}
public void setArchitect_description(String architect_description) {
this.architect_description = architect_description;
}
public void setArchitect_period(String architect_period) {
this.architect_period = architect_period;
}
public void setArchitect_source(String architect_source) {
this.architect_source = architect_source;
}
}
Architects_WordAdapter - CreateViewHolder and BindViewHolder using RecyclerView and I give the data to a new Intent (which is my ArchitectsDetailsActivity.java)
public class Architects_WordAdapter extends RecyclerView.Adapter<Architects_WordAdapter.ViewHolder> {
public List<AZModelArchitects> data;
public Architects_WordAdapter() {
}
public void setData(List<AZModelArchitects> data) {
this.data = data;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Context context = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
View wordView = inflater.inflate(R.layout.entry_list_item, parent, false);
ViewHolder viewHolder = new ViewHolder(wordView, context);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
AZModelArchitects dictionaryModel = data.get(position);
holder.Text1.setText(dictionaryModel.getId());
holder.Text2.setText(dictionaryModel.getArchitect_period());
}
@Override
public int getItemCount() {
return data.size();
}
// int position = getAdapterPosition()-1;
public class ViewHolder extends RecyclerView.ViewHolder {
public Context context;
public TextView Text1;
public TextView Text2;
public ViewHolder(View itemView, final Context context) {
super(itemView);
this.context = context;
Text1 = itemView.findViewById(R.id.textlista);
Text2 = itemView.findViewById(R.id.textlista_cat);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int position = getAdapterPosition();
AZModelArchitects dictionaryModel = data.get(position);
Intent intent = new Intent(context, ArchitectsDetailsActivity.class);
intent.putExtra("architect_name", dictionaryModel.getId());
intent.putExtra("architect_image", dictionaryModel.getArchitect_image());
intent.putExtra("architect_description", dictionaryModel.getArchitect_description());
intent.putExtra("architect_period", dictionaryModel.getArchitect_period());
intent.putExtra("architect_source", dictionaryModel.getArchitect_source());
context.startActivity(intent);
}
});
}
}
}
ArchitectsDetailsActivity.java - get my StringExtra from the Architects_WordAdapter.java
//...
String stringPoza = getIntent().getStringExtra("architect_image");
String stringMainWord = getIntent().getStringExtra("architect_name");
String stringDescription = getIntent().getStringExtra("architect_description");
String stringPeriod = getIntent().getStringExtra("architect_period");
String stringSource = getIntent().getStringExtra("architect_source");
architect_name_Text = findViewById(R.id.mainTextPagina);
viewPoza = findViewById(R.id.poza_pagina_detaliu);
architect_description_Text = findViewById(R.id.architect_description_textafisat);
architect_period_Text = findViewById(R.id.architect_period_textafisat);
architect_source_Text = findViewById(R.id.architect_source_textafisat);
architect_description_Text.setText(Html.fromHtml(stringDescription));
architect_period_Text.setText(Html.fromHtml(stringPeriod));
architect_source_Text.setText(Html.fromHtml(stringSource));
architect_name_Text.setText(Html.fromHtml(stringMainWord));
architect_name_Text.setSelected(true);
toolbar.setTitle(stringMainWord);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mDBHelper = new DatabaseHelperArchitects(this);
findViewById(R.id.left_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to previous entry
//populate the intent with the data from the previous row of the database
}
});
findViewById(R.id.right_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to next entry
//populate the intent with the data from the next row of the database
}
});
try {
InputStream is = assetManager.open("architects/" + stringPoza);
b = BitmapFactory.decodeStream(is);
viewPoza.setImageBitmap(b);
} catch (IOException e) {
Log.e(TAG, e.getMessage());
}
Everything works fine, but I want to put two buttons on my ArchitectsDetailsActivity.java
findViewById(R.id.left_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to previous entry
//populate the intent with the data from the previous row of the database
}
});
findViewById(R.id.right_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to next entry
//populate the intent with the data from the next row of the database
}
});
What can I do it?
java android android-sqlite
add a comment |
I am developing an app and I have the following files:
MainActivity.java - to populate a listview
//...
mDBHelper = new DatabaseHelperArchitects(this);
File database = getApplicationContext().getDatabasePath(DatabaseHelperArchitects.DBNAME);
AZModelArchitectsList = mDBHelper.getListWord("");
word_adapter = new Architects_WordAdapter();
word_adapter.setData(AZModelArchitectsList);
rvWord.setAdapter(word_adapter);
//...
DatabaseHelperArchitects.java - to openDatabase, query the data and add data in a model list, Upgrade database method, Close database method, etc.
public List<AZModelArchitects> getListWord(String wordSearch) {
AZModelArchitects dictionaryModel = null;
List<AZModelArchitects> dictionaryModelList = new ArrayList<>();
openDatabase();
String args = {"%" + wordSearch + "%", "%" + wordSearch + "%"};
cursor = mDatabase.rawQuery("Select * From architects_az Where architect_name Like ? OR architect_period Like ?", args);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
dictionaryModel = new AZModelArchitects(
cursor.getString(1),
cursor.getString(2),
cursor.getString(3),
cursor.getString(4),
cursor.getString(5)
);
dictionaryModelList.add(dictionaryModel);
cursor.moveToNext();
}
cursor.close();
closeDatabase();
return dictionaryModelList;
}
AZModelArchitects - the model
public class AZModelArchitects {
private String id;
private String architect_image;
private String architect_description;
private String architect_period;
private String architect_source;
public AZModelArchitects(String id, String architect_image, String architect_description, String architect_period, String architect_source) {
this.id = id;
this.architect_image = architect_image;
this.architect_description = architect_description;
this.architect_period = architect_period;
this.architect_source = architect_source;
}
public String getId() {
return id;
}
public String getArchitect_image() {
return architect_image;
}
public String getArchitect_description() {
return architect_description;
}
public String getArchitect_period() {
return architect_period;
}
public String getArchitect_source() {
return architect_source;
}
public void setId(String id) {
this.id = id;
}
public void setArchitect_image(String architect_image) {
this.architect_image = architect_image;
}
public void setArchitect_description(String architect_description) {
this.architect_description = architect_description;
}
public void setArchitect_period(String architect_period) {
this.architect_period = architect_period;
}
public void setArchitect_source(String architect_source) {
this.architect_source = architect_source;
}
}
Architects_WordAdapter - CreateViewHolder and BindViewHolder using RecyclerView and I give the data to a new Intent (which is my ArchitectsDetailsActivity.java)
public class Architects_WordAdapter extends RecyclerView.Adapter<Architects_WordAdapter.ViewHolder> {
public List<AZModelArchitects> data;
public Architects_WordAdapter() {
}
public void setData(List<AZModelArchitects> data) {
this.data = data;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Context context = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
View wordView = inflater.inflate(R.layout.entry_list_item, parent, false);
ViewHolder viewHolder = new ViewHolder(wordView, context);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
AZModelArchitects dictionaryModel = data.get(position);
holder.Text1.setText(dictionaryModel.getId());
holder.Text2.setText(dictionaryModel.getArchitect_period());
}
@Override
public int getItemCount() {
return data.size();
}
// int position = getAdapterPosition()-1;
public class ViewHolder extends RecyclerView.ViewHolder {
public Context context;
public TextView Text1;
public TextView Text2;
public ViewHolder(View itemView, final Context context) {
super(itemView);
this.context = context;
Text1 = itemView.findViewById(R.id.textlista);
Text2 = itemView.findViewById(R.id.textlista_cat);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int position = getAdapterPosition();
AZModelArchitects dictionaryModel = data.get(position);
Intent intent = new Intent(context, ArchitectsDetailsActivity.class);
intent.putExtra("architect_name", dictionaryModel.getId());
intent.putExtra("architect_image", dictionaryModel.getArchitect_image());
intent.putExtra("architect_description", dictionaryModel.getArchitect_description());
intent.putExtra("architect_period", dictionaryModel.getArchitect_period());
intent.putExtra("architect_source", dictionaryModel.getArchitect_source());
context.startActivity(intent);
}
});
}
}
}
ArchitectsDetailsActivity.java - get my StringExtra from the Architects_WordAdapter.java
//...
String stringPoza = getIntent().getStringExtra("architect_image");
String stringMainWord = getIntent().getStringExtra("architect_name");
String stringDescription = getIntent().getStringExtra("architect_description");
String stringPeriod = getIntent().getStringExtra("architect_period");
String stringSource = getIntent().getStringExtra("architect_source");
architect_name_Text = findViewById(R.id.mainTextPagina);
viewPoza = findViewById(R.id.poza_pagina_detaliu);
architect_description_Text = findViewById(R.id.architect_description_textafisat);
architect_period_Text = findViewById(R.id.architect_period_textafisat);
architect_source_Text = findViewById(R.id.architect_source_textafisat);
architect_description_Text.setText(Html.fromHtml(stringDescription));
architect_period_Text.setText(Html.fromHtml(stringPeriod));
architect_source_Text.setText(Html.fromHtml(stringSource));
architect_name_Text.setText(Html.fromHtml(stringMainWord));
architect_name_Text.setSelected(true);
toolbar.setTitle(stringMainWord);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mDBHelper = new DatabaseHelperArchitects(this);
findViewById(R.id.left_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to previous entry
//populate the intent with the data from the previous row of the database
}
});
findViewById(R.id.right_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to next entry
//populate the intent with the data from the next row of the database
}
});
try {
InputStream is = assetManager.open("architects/" + stringPoza);
b = BitmapFactory.decodeStream(is);
viewPoza.setImageBitmap(b);
} catch (IOException e) {
Log.e(TAG, e.getMessage());
}
Everything works fine, but I want to put two buttons on my ArchitectsDetailsActivity.java
findViewById(R.id.left_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to previous entry
//populate the intent with the data from the previous row of the database
}
});
findViewById(R.id.right_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to next entry
//populate the intent with the data from the next row of the database
}
});
What can I do it?
java android android-sqlite
i don't know whether it is right approach or not but you can fetch all the data in a array list and then declare a int variable something like index, and when right button is pressed index ++ and on pressing left button index --. display the data from array list that is matched to index.
– Sam.
Nov 20 '18 at 22:28
add a comment |
I am developing an app and I have the following files:
MainActivity.java - to populate a listview
//...
mDBHelper = new DatabaseHelperArchitects(this);
File database = getApplicationContext().getDatabasePath(DatabaseHelperArchitects.DBNAME);
AZModelArchitectsList = mDBHelper.getListWord("");
word_adapter = new Architects_WordAdapter();
word_adapter.setData(AZModelArchitectsList);
rvWord.setAdapter(word_adapter);
//...
DatabaseHelperArchitects.java - to openDatabase, query the data and add data in a model list, Upgrade database method, Close database method, etc.
public List<AZModelArchitects> getListWord(String wordSearch) {
AZModelArchitects dictionaryModel = null;
List<AZModelArchitects> dictionaryModelList = new ArrayList<>();
openDatabase();
String args = {"%" + wordSearch + "%", "%" + wordSearch + "%"};
cursor = mDatabase.rawQuery("Select * From architects_az Where architect_name Like ? OR architect_period Like ?", args);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
dictionaryModel = new AZModelArchitects(
cursor.getString(1),
cursor.getString(2),
cursor.getString(3),
cursor.getString(4),
cursor.getString(5)
);
dictionaryModelList.add(dictionaryModel);
cursor.moveToNext();
}
cursor.close();
closeDatabase();
return dictionaryModelList;
}
AZModelArchitects - the model
public class AZModelArchitects {
private String id;
private String architect_image;
private String architect_description;
private String architect_period;
private String architect_source;
public AZModelArchitects(String id, String architect_image, String architect_description, String architect_period, String architect_source) {
this.id = id;
this.architect_image = architect_image;
this.architect_description = architect_description;
this.architect_period = architect_period;
this.architect_source = architect_source;
}
public String getId() {
return id;
}
public String getArchitect_image() {
return architect_image;
}
public String getArchitect_description() {
return architect_description;
}
public String getArchitect_period() {
return architect_period;
}
public String getArchitect_source() {
return architect_source;
}
public void setId(String id) {
this.id = id;
}
public void setArchitect_image(String architect_image) {
this.architect_image = architect_image;
}
public void setArchitect_description(String architect_description) {
this.architect_description = architect_description;
}
public void setArchitect_period(String architect_period) {
this.architect_period = architect_period;
}
public void setArchitect_source(String architect_source) {
this.architect_source = architect_source;
}
}
Architects_WordAdapter - CreateViewHolder and BindViewHolder using RecyclerView and I give the data to a new Intent (which is my ArchitectsDetailsActivity.java)
public class Architects_WordAdapter extends RecyclerView.Adapter<Architects_WordAdapter.ViewHolder> {
public List<AZModelArchitects> data;
public Architects_WordAdapter() {
}
public void setData(List<AZModelArchitects> data) {
this.data = data;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Context context = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
View wordView = inflater.inflate(R.layout.entry_list_item, parent, false);
ViewHolder viewHolder = new ViewHolder(wordView, context);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
AZModelArchitects dictionaryModel = data.get(position);
holder.Text1.setText(dictionaryModel.getId());
holder.Text2.setText(dictionaryModel.getArchitect_period());
}
@Override
public int getItemCount() {
return data.size();
}
// int position = getAdapterPosition()-1;
public class ViewHolder extends RecyclerView.ViewHolder {
public Context context;
public TextView Text1;
public TextView Text2;
public ViewHolder(View itemView, final Context context) {
super(itemView);
this.context = context;
Text1 = itemView.findViewById(R.id.textlista);
Text2 = itemView.findViewById(R.id.textlista_cat);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int position = getAdapterPosition();
AZModelArchitects dictionaryModel = data.get(position);
Intent intent = new Intent(context, ArchitectsDetailsActivity.class);
intent.putExtra("architect_name", dictionaryModel.getId());
intent.putExtra("architect_image", dictionaryModel.getArchitect_image());
intent.putExtra("architect_description", dictionaryModel.getArchitect_description());
intent.putExtra("architect_period", dictionaryModel.getArchitect_period());
intent.putExtra("architect_source", dictionaryModel.getArchitect_source());
context.startActivity(intent);
}
});
}
}
}
ArchitectsDetailsActivity.java - get my StringExtra from the Architects_WordAdapter.java
//...
String stringPoza = getIntent().getStringExtra("architect_image");
String stringMainWord = getIntent().getStringExtra("architect_name");
String stringDescription = getIntent().getStringExtra("architect_description");
String stringPeriod = getIntent().getStringExtra("architect_period");
String stringSource = getIntent().getStringExtra("architect_source");
architect_name_Text = findViewById(R.id.mainTextPagina);
viewPoza = findViewById(R.id.poza_pagina_detaliu);
architect_description_Text = findViewById(R.id.architect_description_textafisat);
architect_period_Text = findViewById(R.id.architect_period_textafisat);
architect_source_Text = findViewById(R.id.architect_source_textafisat);
architect_description_Text.setText(Html.fromHtml(stringDescription));
architect_period_Text.setText(Html.fromHtml(stringPeriod));
architect_source_Text.setText(Html.fromHtml(stringSource));
architect_name_Text.setText(Html.fromHtml(stringMainWord));
architect_name_Text.setSelected(true);
toolbar.setTitle(stringMainWord);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mDBHelper = new DatabaseHelperArchitects(this);
findViewById(R.id.left_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to previous entry
//populate the intent with the data from the previous row of the database
}
});
findViewById(R.id.right_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to next entry
//populate the intent with the data from the next row of the database
}
});
try {
InputStream is = assetManager.open("architects/" + stringPoza);
b = BitmapFactory.decodeStream(is);
viewPoza.setImageBitmap(b);
} catch (IOException e) {
Log.e(TAG, e.getMessage());
}
Everything works fine, but I want to put two buttons on my ArchitectsDetailsActivity.java
findViewById(R.id.left_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to previous entry
//populate the intent with the data from the previous row of the database
}
});
findViewById(R.id.right_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to next entry
//populate the intent with the data from the next row of the database
}
});
What can I do it?
java android android-sqlite
I am developing an app and I have the following files:
MainActivity.java - to populate a listview
//...
mDBHelper = new DatabaseHelperArchitects(this);
File database = getApplicationContext().getDatabasePath(DatabaseHelperArchitects.DBNAME);
AZModelArchitectsList = mDBHelper.getListWord("");
word_adapter = new Architects_WordAdapter();
word_adapter.setData(AZModelArchitectsList);
rvWord.setAdapter(word_adapter);
//...
DatabaseHelperArchitects.java - to openDatabase, query the data and add data in a model list, Upgrade database method, Close database method, etc.
public List<AZModelArchitects> getListWord(String wordSearch) {
AZModelArchitects dictionaryModel = null;
List<AZModelArchitects> dictionaryModelList = new ArrayList<>();
openDatabase();
String args = {"%" + wordSearch + "%", "%" + wordSearch + "%"};
cursor = mDatabase.rawQuery("Select * From architects_az Where architect_name Like ? OR architect_period Like ?", args);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
dictionaryModel = new AZModelArchitects(
cursor.getString(1),
cursor.getString(2),
cursor.getString(3),
cursor.getString(4),
cursor.getString(5)
);
dictionaryModelList.add(dictionaryModel);
cursor.moveToNext();
}
cursor.close();
closeDatabase();
return dictionaryModelList;
}
AZModelArchitects - the model
public class AZModelArchitects {
private String id;
private String architect_image;
private String architect_description;
private String architect_period;
private String architect_source;
public AZModelArchitects(String id, String architect_image, String architect_description, String architect_period, String architect_source) {
this.id = id;
this.architect_image = architect_image;
this.architect_description = architect_description;
this.architect_period = architect_period;
this.architect_source = architect_source;
}
public String getId() {
return id;
}
public String getArchitect_image() {
return architect_image;
}
public String getArchitect_description() {
return architect_description;
}
public String getArchitect_period() {
return architect_period;
}
public String getArchitect_source() {
return architect_source;
}
public void setId(String id) {
this.id = id;
}
public void setArchitect_image(String architect_image) {
this.architect_image = architect_image;
}
public void setArchitect_description(String architect_description) {
this.architect_description = architect_description;
}
public void setArchitect_period(String architect_period) {
this.architect_period = architect_period;
}
public void setArchitect_source(String architect_source) {
this.architect_source = architect_source;
}
}
Architects_WordAdapter - CreateViewHolder and BindViewHolder using RecyclerView and I give the data to a new Intent (which is my ArchitectsDetailsActivity.java)
public class Architects_WordAdapter extends RecyclerView.Adapter<Architects_WordAdapter.ViewHolder> {
public List<AZModelArchitects> data;
public Architects_WordAdapter() {
}
public void setData(List<AZModelArchitects> data) {
this.data = data;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Context context = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
View wordView = inflater.inflate(R.layout.entry_list_item, parent, false);
ViewHolder viewHolder = new ViewHolder(wordView, context);
return viewHolder;
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
AZModelArchitects dictionaryModel = data.get(position);
holder.Text1.setText(dictionaryModel.getId());
holder.Text2.setText(dictionaryModel.getArchitect_period());
}
@Override
public int getItemCount() {
return data.size();
}
// int position = getAdapterPosition()-1;
public class ViewHolder extends RecyclerView.ViewHolder {
public Context context;
public TextView Text1;
public TextView Text2;
public ViewHolder(View itemView, final Context context) {
super(itemView);
this.context = context;
Text1 = itemView.findViewById(R.id.textlista);
Text2 = itemView.findViewById(R.id.textlista_cat);
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int position = getAdapterPosition();
AZModelArchitects dictionaryModel = data.get(position);
Intent intent = new Intent(context, ArchitectsDetailsActivity.class);
intent.putExtra("architect_name", dictionaryModel.getId());
intent.putExtra("architect_image", dictionaryModel.getArchitect_image());
intent.putExtra("architect_description", dictionaryModel.getArchitect_description());
intent.putExtra("architect_period", dictionaryModel.getArchitect_period());
intent.putExtra("architect_source", dictionaryModel.getArchitect_source());
context.startActivity(intent);
}
});
}
}
}
ArchitectsDetailsActivity.java - get my StringExtra from the Architects_WordAdapter.java
//...
String stringPoza = getIntent().getStringExtra("architect_image");
String stringMainWord = getIntent().getStringExtra("architect_name");
String stringDescription = getIntent().getStringExtra("architect_description");
String stringPeriod = getIntent().getStringExtra("architect_period");
String stringSource = getIntent().getStringExtra("architect_source");
architect_name_Text = findViewById(R.id.mainTextPagina);
viewPoza = findViewById(R.id.poza_pagina_detaliu);
architect_description_Text = findViewById(R.id.architect_description_textafisat);
architect_period_Text = findViewById(R.id.architect_period_textafisat);
architect_source_Text = findViewById(R.id.architect_source_textafisat);
architect_description_Text.setText(Html.fromHtml(stringDescription));
architect_period_Text.setText(Html.fromHtml(stringPeriod));
architect_source_Text.setText(Html.fromHtml(stringSource));
architect_name_Text.setText(Html.fromHtml(stringMainWord));
architect_name_Text.setSelected(true);
toolbar.setTitle(stringMainWord);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mDBHelper = new DatabaseHelperArchitects(this);
findViewById(R.id.left_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to previous entry
//populate the intent with the data from the previous row of the database
}
});
findViewById(R.id.right_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to next entry
//populate the intent with the data from the next row of the database
}
});
try {
InputStream is = assetManager.open("architects/" + stringPoza);
b = BitmapFactory.decodeStream(is);
viewPoza.setImageBitmap(b);
} catch (IOException e) {
Log.e(TAG, e.getMessage());
}
Everything works fine, but I want to put two buttons on my ArchitectsDetailsActivity.java
findViewById(R.id.left_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to previous entry
//populate the intent with the data from the previous row of the database
}
});
findViewById(R.id.right_action_button_location).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//move to next entry
//populate the intent with the data from the next row of the database
}
});
What can I do it?
java android android-sqlite
java android android-sqlite
edited Nov 21 '18 at 10:06
asked Nov 20 '18 at 19:34
Apopei Andrei Ionut
149421
149421
i don't know whether it is right approach or not but you can fetch all the data in a array list and then declare a int variable something like index, and when right button is pressed index ++ and on pressing left button index --. display the data from array list that is matched to index.
– Sam.
Nov 20 '18 at 22:28
add a comment |
i don't know whether it is right approach or not but you can fetch all the data in a array list and then declare a int variable something like index, and when right button is pressed index ++ and on pressing left button index --. display the data from array list that is matched to index.
– Sam.
Nov 20 '18 at 22:28
i don't know whether it is right approach or not but you can fetch all the data in a array list and then declare a int variable something like index, and when right button is pressed index ++ and on pressing left button index --. display the data from array list that is matched to index.
– Sam.
Nov 20 '18 at 22:28
i don't know whether it is right approach or not but you can fetch all the data in a array list and then declare a int variable something like index, and when right button is pressed index ++ and on pressing left button index --. display the data from array list that is matched to index.
– Sam.
Nov 20 '18 at 22:28
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400302%2fnavigate-to-the-next-entry-in-sqlite-database-android%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400302%2fnavigate-to-the-next-entry-in-sqlite-database-android%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
i don't know whether it is right approach or not but you can fetch all the data in a array list and then declare a int variable something like index, and when right button is pressed index ++ and on pressing left button index --. display the data from array list that is matched to index.
– Sam.
Nov 20 '18 at 22:28