RecyclerView not filling(Arrays)












2















I searched a lot but cannot find out why my RecyclerView is not showing all data.
When printing data to the console in "MySensorAdapter" the values are complete.



Code is below, thank you very much.



public class MySensorAdapter extends RecyclerView.Adapter {



private String mKeys;
private String mValues;

public MySensorAdapter(HashMap<String, String> dictionary){
mKeys = new String[dictionary.size()];
mValues = new String[dictionary.size()];

for(String i : dictionary.keySet()){
int count = 0;
mKeys[count]=i;
mValues[count] = dictionary.get(i);
count++;
}

}

public static class MyViewHolder extends RecyclerView.ViewHolder{

public TextView mTextViewTitle;
public TextView mTextViewData;

public MyViewHolder(View v){
super(v);
mTextViewTitle = v.findViewById(R.id.textViewTitle);
mTextViewData = v.findViewById(R.id.textViewData);
}
}

@NonNull
@Override
public MySensorAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.my_sensor_item, parent, false);

MySensorAdapter.MyViewHolder viewHolder = new MySensorAdapter.MyViewHolder(v);
return viewHolder;
}

@Override
public void onBindViewHolder(@NonNull MySensorAdapter.MyViewHolder holder, int position) {
String title=mKeys[position];
String data=mValues[position];

Log.i("DEBUG POSITION", String.valueOf(position));

holder.mTextViewTitle.setText(title);
holder.mTextViewData.setText(data);
}

@Override
public int getItemCount() {
if(mKeys != null){
Log.i("DEBUG LENGTH", String.valueOf(mKeys.length));

return mKeys.length;
}
return 0;
}


}



EDIT: Maybe this might help too. I just want to display a sensors information in a recyclerview



public class SensorDataActivity extends AppCompatActivity implements SensorEventListener {

private SensorManager mSensormanager;

private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;

private HashMap<String, String> list = new HashMap<>();

private Sensor mSensor;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sensor_data);

Intent intent = getIntent();
int position = intent.getIntExtra("position", 0);

Log.i("WICHTIG", String.valueOf(position));


mSensormanager = (SensorManager) getSystemService(SENSOR_SERVICE);
assert mSensormanager != null;
List<Sensor> sensors = mSensormanager.getSensorList(Sensor.TYPE_ALL);



//Debugging to be done!
int type = sensors.get(position).getType();

Log.i("WICHTIG", String.valueOf(type));

mSensor = mSensormanager.getDefaultSensor(type);

getSensorInformation(mSensor);

mRecyclerView = findViewById(R.id.my_sensor_recycler_view);
mRecyclerView.setHasFixedSize(true);

mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);

mAdapter = new MySensorAdapter(list);
mRecyclerView.setAdapter(mAdapter);

}

private void getSensorInformation(Sensor sensor){

list.put("Name", sensor.getName());
list.put("Type", String.valueOf(sensor.getType()));
list.put("Version", String.valueOf(sensor.getVersion()));

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
list.put("Id", String.valueOf(sensor.getId()));
list.put("Type(String)", sensor.getStringType());
}

list.put("Power", String.valueOf(sensor.getPower()));
list.put("Vendor",sensor.getVendor());
list.put("MaximumRange",String.valueOf(sensor.getMaximumRange()));
list.put("Resolution",String.valueOf(sensor.getResolution()));
list.put("MinDelay",String.valueOf(sensor.getMinDelay()));


if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
list.put("MaximumDelay",String.valueOf(sensor.getMaxDelay()));
list.put("FifoMaxEvent",String.valueOf(sensor.getFifoMaxEventCount()));
list.put("FifoReservedEvent",String.valueOf(sensor.getFifoReservedEventCount()));
list.put("ReportingMode",String.valueOf(sensor.getReportingMode()));
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
list.put("HighestDirectReportRate",String.valueOf(sensor.getHighestDirectReportRateLevel()));
}



}

@Override
public void onSensorChanged(SensorEvent event) {

for(int i = 0; i<event.values.length; i++) {

String key = "Value"+String.valueOf(i);

list.put(key, String.valueOf(event.values[i]));
}

mAdapter.notifyDataSetChanged();

}

@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
list.put("Accuracy", String.valueOf(accuracy));
mAdapter.notifyDataSetChanged();
}

@Override
protected void onResume() {
super.onResume();
mSensormanager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL);
}

@Override
protected void onPause() {
super.onPause();
mSensormanager.unregisterListener(this);
}

}











share|improve this question

























  • Have you setLayoutManager for the recycler view?

    – jaede
    Nov 24 '18 at 12:32











  • Yes, see my edits for more details. It worked all fine by passing an Array but because I had to pick a dictionary due the "OnSensorChange", if only displays one item (name) in my recyclerview

    – Taka
    Nov 24 '18 at 12:38











  • there are no errors. only weird rendering of my recyclerview

    – Taka
    Nov 24 '18 at 12:40











  • they are not complete or they are not showing at all? can you post a screenshot of the result? that might help

    – Master Fathi
    Nov 24 '18 at 12:43











  • only the first item is visible ?

    – jaede
    Nov 24 '18 at 13:06
















2















I searched a lot but cannot find out why my RecyclerView is not showing all data.
When printing data to the console in "MySensorAdapter" the values are complete.



Code is below, thank you very much.



public class MySensorAdapter extends RecyclerView.Adapter {



private String mKeys;
private String mValues;

public MySensorAdapter(HashMap<String, String> dictionary){
mKeys = new String[dictionary.size()];
mValues = new String[dictionary.size()];

for(String i : dictionary.keySet()){
int count = 0;
mKeys[count]=i;
mValues[count] = dictionary.get(i);
count++;
}

}

public static class MyViewHolder extends RecyclerView.ViewHolder{

public TextView mTextViewTitle;
public TextView mTextViewData;

public MyViewHolder(View v){
super(v);
mTextViewTitle = v.findViewById(R.id.textViewTitle);
mTextViewData = v.findViewById(R.id.textViewData);
}
}

@NonNull
@Override
public MySensorAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.my_sensor_item, parent, false);

MySensorAdapter.MyViewHolder viewHolder = new MySensorAdapter.MyViewHolder(v);
return viewHolder;
}

@Override
public void onBindViewHolder(@NonNull MySensorAdapter.MyViewHolder holder, int position) {
String title=mKeys[position];
String data=mValues[position];

Log.i("DEBUG POSITION", String.valueOf(position));

holder.mTextViewTitle.setText(title);
holder.mTextViewData.setText(data);
}

@Override
public int getItemCount() {
if(mKeys != null){
Log.i("DEBUG LENGTH", String.valueOf(mKeys.length));

return mKeys.length;
}
return 0;
}


}



EDIT: Maybe this might help too. I just want to display a sensors information in a recyclerview



public class SensorDataActivity extends AppCompatActivity implements SensorEventListener {

private SensorManager mSensormanager;

private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;

private HashMap<String, String> list = new HashMap<>();

private Sensor mSensor;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sensor_data);

Intent intent = getIntent();
int position = intent.getIntExtra("position", 0);

Log.i("WICHTIG", String.valueOf(position));


mSensormanager = (SensorManager) getSystemService(SENSOR_SERVICE);
assert mSensormanager != null;
List<Sensor> sensors = mSensormanager.getSensorList(Sensor.TYPE_ALL);



//Debugging to be done!
int type = sensors.get(position).getType();

Log.i("WICHTIG", String.valueOf(type));

mSensor = mSensormanager.getDefaultSensor(type);

getSensorInformation(mSensor);

mRecyclerView = findViewById(R.id.my_sensor_recycler_view);
mRecyclerView.setHasFixedSize(true);

mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);

mAdapter = new MySensorAdapter(list);
mRecyclerView.setAdapter(mAdapter);

}

private void getSensorInformation(Sensor sensor){

list.put("Name", sensor.getName());
list.put("Type", String.valueOf(sensor.getType()));
list.put("Version", String.valueOf(sensor.getVersion()));

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
list.put("Id", String.valueOf(sensor.getId()));
list.put("Type(String)", sensor.getStringType());
}

list.put("Power", String.valueOf(sensor.getPower()));
list.put("Vendor",sensor.getVendor());
list.put("MaximumRange",String.valueOf(sensor.getMaximumRange()));
list.put("Resolution",String.valueOf(sensor.getResolution()));
list.put("MinDelay",String.valueOf(sensor.getMinDelay()));


if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
list.put("MaximumDelay",String.valueOf(sensor.getMaxDelay()));
list.put("FifoMaxEvent",String.valueOf(sensor.getFifoMaxEventCount()));
list.put("FifoReservedEvent",String.valueOf(sensor.getFifoReservedEventCount()));
list.put("ReportingMode",String.valueOf(sensor.getReportingMode()));
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
list.put("HighestDirectReportRate",String.valueOf(sensor.getHighestDirectReportRateLevel()));
}



}

@Override
public void onSensorChanged(SensorEvent event) {

for(int i = 0; i<event.values.length; i++) {

String key = "Value"+String.valueOf(i);

list.put(key, String.valueOf(event.values[i]));
}

mAdapter.notifyDataSetChanged();

}

@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
list.put("Accuracy", String.valueOf(accuracy));
mAdapter.notifyDataSetChanged();
}

@Override
protected void onResume() {
super.onResume();
mSensormanager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL);
}

@Override
protected void onPause() {
super.onPause();
mSensormanager.unregisterListener(this);
}

}











share|improve this question

























  • Have you setLayoutManager for the recycler view?

    – jaede
    Nov 24 '18 at 12:32











  • Yes, see my edits for more details. It worked all fine by passing an Array but because I had to pick a dictionary due the "OnSensorChange", if only displays one item (name) in my recyclerview

    – Taka
    Nov 24 '18 at 12:38











  • there are no errors. only weird rendering of my recyclerview

    – Taka
    Nov 24 '18 at 12:40











  • they are not complete or they are not showing at all? can you post a screenshot of the result? that might help

    – Master Fathi
    Nov 24 '18 at 12:43











  • only the first item is visible ?

    – jaede
    Nov 24 '18 at 13:06














2












2








2








I searched a lot but cannot find out why my RecyclerView is not showing all data.
When printing data to the console in "MySensorAdapter" the values are complete.



Code is below, thank you very much.



public class MySensorAdapter extends RecyclerView.Adapter {



private String mKeys;
private String mValues;

public MySensorAdapter(HashMap<String, String> dictionary){
mKeys = new String[dictionary.size()];
mValues = new String[dictionary.size()];

for(String i : dictionary.keySet()){
int count = 0;
mKeys[count]=i;
mValues[count] = dictionary.get(i);
count++;
}

}

public static class MyViewHolder extends RecyclerView.ViewHolder{

public TextView mTextViewTitle;
public TextView mTextViewData;

public MyViewHolder(View v){
super(v);
mTextViewTitle = v.findViewById(R.id.textViewTitle);
mTextViewData = v.findViewById(R.id.textViewData);
}
}

@NonNull
@Override
public MySensorAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.my_sensor_item, parent, false);

MySensorAdapter.MyViewHolder viewHolder = new MySensorAdapter.MyViewHolder(v);
return viewHolder;
}

@Override
public void onBindViewHolder(@NonNull MySensorAdapter.MyViewHolder holder, int position) {
String title=mKeys[position];
String data=mValues[position];

Log.i("DEBUG POSITION", String.valueOf(position));

holder.mTextViewTitle.setText(title);
holder.mTextViewData.setText(data);
}

@Override
public int getItemCount() {
if(mKeys != null){
Log.i("DEBUG LENGTH", String.valueOf(mKeys.length));

return mKeys.length;
}
return 0;
}


}



EDIT: Maybe this might help too. I just want to display a sensors information in a recyclerview



public class SensorDataActivity extends AppCompatActivity implements SensorEventListener {

private SensorManager mSensormanager;

private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;

private HashMap<String, String> list = new HashMap<>();

private Sensor mSensor;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sensor_data);

Intent intent = getIntent();
int position = intent.getIntExtra("position", 0);

Log.i("WICHTIG", String.valueOf(position));


mSensormanager = (SensorManager) getSystemService(SENSOR_SERVICE);
assert mSensormanager != null;
List<Sensor> sensors = mSensormanager.getSensorList(Sensor.TYPE_ALL);



//Debugging to be done!
int type = sensors.get(position).getType();

Log.i("WICHTIG", String.valueOf(type));

mSensor = mSensormanager.getDefaultSensor(type);

getSensorInformation(mSensor);

mRecyclerView = findViewById(R.id.my_sensor_recycler_view);
mRecyclerView.setHasFixedSize(true);

mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);

mAdapter = new MySensorAdapter(list);
mRecyclerView.setAdapter(mAdapter);

}

private void getSensorInformation(Sensor sensor){

list.put("Name", sensor.getName());
list.put("Type", String.valueOf(sensor.getType()));
list.put("Version", String.valueOf(sensor.getVersion()));

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
list.put("Id", String.valueOf(sensor.getId()));
list.put("Type(String)", sensor.getStringType());
}

list.put("Power", String.valueOf(sensor.getPower()));
list.put("Vendor",sensor.getVendor());
list.put("MaximumRange",String.valueOf(sensor.getMaximumRange()));
list.put("Resolution",String.valueOf(sensor.getResolution()));
list.put("MinDelay",String.valueOf(sensor.getMinDelay()));


if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
list.put("MaximumDelay",String.valueOf(sensor.getMaxDelay()));
list.put("FifoMaxEvent",String.valueOf(sensor.getFifoMaxEventCount()));
list.put("FifoReservedEvent",String.valueOf(sensor.getFifoReservedEventCount()));
list.put("ReportingMode",String.valueOf(sensor.getReportingMode()));
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
list.put("HighestDirectReportRate",String.valueOf(sensor.getHighestDirectReportRateLevel()));
}



}

@Override
public void onSensorChanged(SensorEvent event) {

for(int i = 0; i<event.values.length; i++) {

String key = "Value"+String.valueOf(i);

list.put(key, String.valueOf(event.values[i]));
}

mAdapter.notifyDataSetChanged();

}

@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
list.put("Accuracy", String.valueOf(accuracy));
mAdapter.notifyDataSetChanged();
}

@Override
protected void onResume() {
super.onResume();
mSensormanager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL);
}

@Override
protected void onPause() {
super.onPause();
mSensormanager.unregisterListener(this);
}

}











share|improve this question
















I searched a lot but cannot find out why my RecyclerView is not showing all data.
When printing data to the console in "MySensorAdapter" the values are complete.



Code is below, thank you very much.



public class MySensorAdapter extends RecyclerView.Adapter {



private String mKeys;
private String mValues;

public MySensorAdapter(HashMap<String, String> dictionary){
mKeys = new String[dictionary.size()];
mValues = new String[dictionary.size()];

for(String i : dictionary.keySet()){
int count = 0;
mKeys[count]=i;
mValues[count] = dictionary.get(i);
count++;
}

}

public static class MyViewHolder extends RecyclerView.ViewHolder{

public TextView mTextViewTitle;
public TextView mTextViewData;

public MyViewHolder(View v){
super(v);
mTextViewTitle = v.findViewById(R.id.textViewTitle);
mTextViewData = v.findViewById(R.id.textViewData);
}
}

@NonNull
@Override
public MySensorAdapter.MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.my_sensor_item, parent, false);

MySensorAdapter.MyViewHolder viewHolder = new MySensorAdapter.MyViewHolder(v);
return viewHolder;
}

@Override
public void onBindViewHolder(@NonNull MySensorAdapter.MyViewHolder holder, int position) {
String title=mKeys[position];
String data=mValues[position];

Log.i("DEBUG POSITION", String.valueOf(position));

holder.mTextViewTitle.setText(title);
holder.mTextViewData.setText(data);
}

@Override
public int getItemCount() {
if(mKeys != null){
Log.i("DEBUG LENGTH", String.valueOf(mKeys.length));

return mKeys.length;
}
return 0;
}


}



EDIT: Maybe this might help too. I just want to display a sensors information in a recyclerview



public class SensorDataActivity extends AppCompatActivity implements SensorEventListener {

private SensorManager mSensormanager;

private RecyclerView mRecyclerView;
private RecyclerView.Adapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;

private HashMap<String, String> list = new HashMap<>();

private Sensor mSensor;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sensor_data);

Intent intent = getIntent();
int position = intent.getIntExtra("position", 0);

Log.i("WICHTIG", String.valueOf(position));


mSensormanager = (SensorManager) getSystemService(SENSOR_SERVICE);
assert mSensormanager != null;
List<Sensor> sensors = mSensormanager.getSensorList(Sensor.TYPE_ALL);



//Debugging to be done!
int type = sensors.get(position).getType();

Log.i("WICHTIG", String.valueOf(type));

mSensor = mSensormanager.getDefaultSensor(type);

getSensorInformation(mSensor);

mRecyclerView = findViewById(R.id.my_sensor_recycler_view);
mRecyclerView.setHasFixedSize(true);

mLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLayoutManager);

mAdapter = new MySensorAdapter(list);
mRecyclerView.setAdapter(mAdapter);

}

private void getSensorInformation(Sensor sensor){

list.put("Name", sensor.getName());
list.put("Type", String.valueOf(sensor.getType()));
list.put("Version", String.valueOf(sensor.getVersion()));

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
list.put("Id", String.valueOf(sensor.getId()));
list.put("Type(String)", sensor.getStringType());
}

list.put("Power", String.valueOf(sensor.getPower()));
list.put("Vendor",sensor.getVendor());
list.put("MaximumRange",String.valueOf(sensor.getMaximumRange()));
list.put("Resolution",String.valueOf(sensor.getResolution()));
list.put("MinDelay",String.valueOf(sensor.getMinDelay()));


if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
list.put("MaximumDelay",String.valueOf(sensor.getMaxDelay()));
list.put("FifoMaxEvent",String.valueOf(sensor.getFifoMaxEventCount()));
list.put("FifoReservedEvent",String.valueOf(sensor.getFifoReservedEventCount()));
list.put("ReportingMode",String.valueOf(sensor.getReportingMode()));
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
list.put("HighestDirectReportRate",String.valueOf(sensor.getHighestDirectReportRateLevel()));
}



}

@Override
public void onSensorChanged(SensorEvent event) {

for(int i = 0; i<event.values.length; i++) {

String key = "Value"+String.valueOf(i);

list.put(key, String.valueOf(event.values[i]));
}

mAdapter.notifyDataSetChanged();

}

@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
list.put("Accuracy", String.valueOf(accuracy));
mAdapter.notifyDataSetChanged();
}

@Override
protected void onResume() {
super.onResume();
mSensormanager.registerListener(this, mSensor, SensorManager.SENSOR_DELAY_NORMAL);
}

@Override
protected void onPause() {
super.onPause();
mSensormanager.unregisterListener(this);
}

}








android android-studio android-recyclerview






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 11:08









Ashvin solanki

1,451627




1,451627










asked Nov 24 '18 at 12:29









TakaTaka

135




135













  • Have you setLayoutManager for the recycler view?

    – jaede
    Nov 24 '18 at 12:32











  • Yes, see my edits for more details. It worked all fine by passing an Array but because I had to pick a dictionary due the "OnSensorChange", if only displays one item (name) in my recyclerview

    – Taka
    Nov 24 '18 at 12:38











  • there are no errors. only weird rendering of my recyclerview

    – Taka
    Nov 24 '18 at 12:40











  • they are not complete or they are not showing at all? can you post a screenshot of the result? that might help

    – Master Fathi
    Nov 24 '18 at 12:43











  • only the first item is visible ?

    – jaede
    Nov 24 '18 at 13:06



















  • Have you setLayoutManager for the recycler view?

    – jaede
    Nov 24 '18 at 12:32











  • Yes, see my edits for more details. It worked all fine by passing an Array but because I had to pick a dictionary due the "OnSensorChange", if only displays one item (name) in my recyclerview

    – Taka
    Nov 24 '18 at 12:38











  • there are no errors. only weird rendering of my recyclerview

    – Taka
    Nov 24 '18 at 12:40











  • they are not complete or they are not showing at all? can you post a screenshot of the result? that might help

    – Master Fathi
    Nov 24 '18 at 12:43











  • only the first item is visible ?

    – jaede
    Nov 24 '18 at 13:06

















Have you setLayoutManager for the recycler view?

– jaede
Nov 24 '18 at 12:32





Have you setLayoutManager for the recycler view?

– jaede
Nov 24 '18 at 12:32













Yes, see my edits for more details. It worked all fine by passing an Array but because I had to pick a dictionary due the "OnSensorChange", if only displays one item (name) in my recyclerview

– Taka
Nov 24 '18 at 12:38





Yes, see my edits for more details. It worked all fine by passing an Array but because I had to pick a dictionary due the "OnSensorChange", if only displays one item (name) in my recyclerview

– Taka
Nov 24 '18 at 12:38













there are no errors. only weird rendering of my recyclerview

– Taka
Nov 24 '18 at 12:40





there are no errors. only weird rendering of my recyclerview

– Taka
Nov 24 '18 at 12:40













they are not complete or they are not showing at all? can you post a screenshot of the result? that might help

– Master Fathi
Nov 24 '18 at 12:43





they are not complete or they are not showing at all? can you post a screenshot of the result? that might help

– Master Fathi
Nov 24 '18 at 12:43













only the first item is visible ?

– jaede
Nov 24 '18 at 13:06





only the first item is visible ?

– jaede
Nov 24 '18 at 13:06












2 Answers
2






active

oldest

votes


















1














The count value is reset to 0 every time in the



for(String i : dictionary.keySet()){
int count = 0;
mKeys[count]=i;
mValues[count] = dictionary.get(i);
count++;
}


Hence the dataset that is used to display the UI has just one element every time.
You can try initialising the count outside the loop.






share|improve this answer
























  • This is so frustrating to have done such a dumb mistake! Thank you so much, I was literally in despair.

    – Taka
    Nov 25 '18 at 15:02











  • Its alright. Happy to have solved the issue. Cheers!

    – jaede
    Nov 25 '18 at 15:07



















1














Just remove from your adapter constructor int count = 0; from the loop initialize it outside before the loop like this



public MySensorAdapter(HashMap<String, String> dictionary) {
mKeys = new String[dictionary.size()];
mValues = new String[dictionary.size()];
int count = 0;
for (String i : dictionary.keySet()) {
mKeys[count] = i;
mValues[count] = dictionary.get(i);
count++;
}

}


and you're good to go






share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53458155%2frecyclerview-not-fillingarrays%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    The count value is reset to 0 every time in the



    for(String i : dictionary.keySet()){
    int count = 0;
    mKeys[count]=i;
    mValues[count] = dictionary.get(i);
    count++;
    }


    Hence the dataset that is used to display the UI has just one element every time.
    You can try initialising the count outside the loop.






    share|improve this answer
























    • This is so frustrating to have done such a dumb mistake! Thank you so much, I was literally in despair.

      – Taka
      Nov 25 '18 at 15:02











    • Its alright. Happy to have solved the issue. Cheers!

      – jaede
      Nov 25 '18 at 15:07
















    1














    The count value is reset to 0 every time in the



    for(String i : dictionary.keySet()){
    int count = 0;
    mKeys[count]=i;
    mValues[count] = dictionary.get(i);
    count++;
    }


    Hence the dataset that is used to display the UI has just one element every time.
    You can try initialising the count outside the loop.






    share|improve this answer
























    • This is so frustrating to have done such a dumb mistake! Thank you so much, I was literally in despair.

      – Taka
      Nov 25 '18 at 15:02











    • Its alright. Happy to have solved the issue. Cheers!

      – jaede
      Nov 25 '18 at 15:07














    1












    1








    1







    The count value is reset to 0 every time in the



    for(String i : dictionary.keySet()){
    int count = 0;
    mKeys[count]=i;
    mValues[count] = dictionary.get(i);
    count++;
    }


    Hence the dataset that is used to display the UI has just one element every time.
    You can try initialising the count outside the loop.






    share|improve this answer













    The count value is reset to 0 every time in the



    for(String i : dictionary.keySet()){
    int count = 0;
    mKeys[count]=i;
    mValues[count] = dictionary.get(i);
    count++;
    }


    Hence the dataset that is used to display the UI has just one element every time.
    You can try initialising the count outside the loop.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 24 '18 at 13:10









    jaedejaede

    16410




    16410













    • This is so frustrating to have done such a dumb mistake! Thank you so much, I was literally in despair.

      – Taka
      Nov 25 '18 at 15:02











    • Its alright. Happy to have solved the issue. Cheers!

      – jaede
      Nov 25 '18 at 15:07



















    • This is so frustrating to have done such a dumb mistake! Thank you so much, I was literally in despair.

      – Taka
      Nov 25 '18 at 15:02











    • Its alright. Happy to have solved the issue. Cheers!

      – jaede
      Nov 25 '18 at 15:07

















    This is so frustrating to have done such a dumb mistake! Thank you so much, I was literally in despair.

    – Taka
    Nov 25 '18 at 15:02





    This is so frustrating to have done such a dumb mistake! Thank you so much, I was literally in despair.

    – Taka
    Nov 25 '18 at 15:02













    Its alright. Happy to have solved the issue. Cheers!

    – jaede
    Nov 25 '18 at 15:07





    Its alright. Happy to have solved the issue. Cheers!

    – jaede
    Nov 25 '18 at 15:07













    1














    Just remove from your adapter constructor int count = 0; from the loop initialize it outside before the loop like this



    public MySensorAdapter(HashMap<String, String> dictionary) {
    mKeys = new String[dictionary.size()];
    mValues = new String[dictionary.size()];
    int count = 0;
    for (String i : dictionary.keySet()) {
    mKeys[count] = i;
    mValues[count] = dictionary.get(i);
    count++;
    }

    }


    and you're good to go






    share|improve this answer




























      1














      Just remove from your adapter constructor int count = 0; from the loop initialize it outside before the loop like this



      public MySensorAdapter(HashMap<String, String> dictionary) {
      mKeys = new String[dictionary.size()];
      mValues = new String[dictionary.size()];
      int count = 0;
      for (String i : dictionary.keySet()) {
      mKeys[count] = i;
      mValues[count] = dictionary.get(i);
      count++;
      }

      }


      and you're good to go






      share|improve this answer


























        1












        1








        1







        Just remove from your adapter constructor int count = 0; from the loop initialize it outside before the loop like this



        public MySensorAdapter(HashMap<String, String> dictionary) {
        mKeys = new String[dictionary.size()];
        mValues = new String[dictionary.size()];
        int count = 0;
        for (String i : dictionary.keySet()) {
        mKeys[count] = i;
        mValues[count] = dictionary.get(i);
        count++;
        }

        }


        and you're good to go






        share|improve this answer













        Just remove from your adapter constructor int count = 0; from the loop initialize it outside before the loop like this



        public MySensorAdapter(HashMap<String, String> dictionary) {
        mKeys = new String[dictionary.size()];
        mValues = new String[dictionary.size()];
        int count = 0;
        for (String i : dictionary.keySet()) {
        mKeys[count] = i;
        mValues[count] = dictionary.get(i);
        count++;
        }

        }


        and you're good to go







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 24 '18 at 13:38









        Master FathiMaster Fathi

        3381816




        3381816






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53458155%2frecyclerview-not-fillingarrays%23new-answer', 'question_page');
            }
            );

            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







            Popular posts from this blog

            Ottavio Pratesi

            Tricia Helfer

            15 giugno