package zero.zd.zquestionnaire;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class LoadQnaActivity extends AppCompatActivity {

    private static final String TAG = LoadQnaActivity.class.getSimpleName();

    private List<String> mQnaFileList;
    private String mSelectedName;


    public static Intent getStartIntent(Context context) {
        return new Intent(context, LoadQnaActivity.class);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_load_qna);
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }

        mQnaFileList = new ArrayList<>();

        ListView list = (ListView) findViewById(R.id.list);
        ArrayAdapter<String> adapter =
                new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mQnaFileList);
        list.setAdapter(adapter);

        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                mSelectedName = mQnaFileList.get(position);
            }
        });
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                finish();
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public void onClickLoad(View view) {
        Toast.makeText(LoadQnaActivity.this, mSelectedName, Toast.LENGTH_SHORT).show();

        // populate qna
        ArrayList<QnA> qnaList = QnAHelper.getBasicQnA();
        Collections.shuffle(qnaList);
        QnaState.getInstance().setQnAList(qnaList);
        Log.d(TAG, "QnA Populated");

        startActivity(QnaAnswerActivity.getStartIntent(LoadQnaActivity.this));
    }

//    /**
//     * Method used to initialize/populate QnA data into QnAList
//     */
//    private void populateQnA() {
//        mQnAList = new ArrayList<>();
//        mQnAList = QnAHelper.getBasicQnA();
//        Collections.shuffle(mQnAList);
//        QnaState.getInstance().setQnAList(mQnAList);
//    }
}

@@ -652,83 +652,8 @@
 );%0A%0A
-    private List%3CString%3E mQnaFileList;%0A    private String mSelectedName;%0A%0A%0A
     
@@ -1066,1562 +1066,274 @@
   %7D%0A
-%0A        mQnaFileList = new ArrayList%3C%3E();%0A%0A        ListView list = (ListView) findViewById(R.id.list);%0A        ArrayAdapter%3CString%3E adapter =%0A                new ArrayAdapter%3C%3E(this, android.R.layout.simple_list_item_1, mQnaFileList);%0A        list.setAdapter(adapter);%0A%0A        list.setOnItemClickListener(new AdapterView.OnItemClickListener() %7B%0A            @Override%0A            public void onItemClick(AdapterView%3C?%3E parent, View view, int position, long id) %7B%0A                mSelectedName = mQnaFileList.get(position);%0A            %7D%0A        %7D);%0A    %7D%0A%0A    @Override%0A    public boolean onOptionsItemSelected(MenuItem item) %7B%0A        switch (item.getItemId()) %7B%0A            case android.R.id.home:%0A                finish();%0A                return true;%0A        %7D%0A        return super.onOptionsItemSelected(item);%0A    %7D%0A%0A    public void onClickLoad(View view) %7B%0A        Toast.makeText(LoadQnaActivity.this, mSelectedName, Toast.LENGTH_SHORT).show();%0A%0A        // populate qna%0A        ArrayList%3CQnA%3E qnaList = QnAHelper.getBasicQnA();%0A        Collections.shuffle(qnaList);%0A        QnaState.getInstance().setQnAList(qnaList);%0A        Log.d(TAG, %22QnA Populated%22);%0A%0A        startActivity(QnaAnswerActivity.getStartIntent(LoadQnaActivity.this));%0A    %7D%0A%0A//    /**%0A//     * Method used to initialize/populate QnA data into QnAList%0A//     */%0A//    private void populateQnA() %7B%0A//        mQnAList = new ArrayList%3C%3E();%0A//        mQnAList = QnAHelper.getBasicQnA();%0A//        Collections.shuffle(mQnAList);%0A//        QnaState.getInstance().setQnAList(mQnAList);%0A//
+    %7D%0A%0A    @Override%0A    public boolean onOptionsItemSelected(MenuItem item) %7B%0A        switch (item.getItemId()) %7B%0A            case android.R.id.home:%0A                finish();%0A                return true;%0A        %7D%0A        return super.onOptionsItemSelected(item);%0A
     

Remove Base Code of Load QnA