title: Android custom listview layout
body: <p>im new to android and java programming. Im having trouble getting my custom layout (currently with only one textview in it to work with my code. I have followed many tutorials and look and many examples but still Im getting confused as to how I would integrate it with my existing code. </p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class checkListActivity extends MainActivity {
  static String filename = "checkList";
  String currentList;
  SharedPreferences checkListData;
  SharedPreferences.Editor checkListEditor;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.checklist);
      Button bAddItem = (Button) findViewById(R.id.bAddItem);
      final EditText etItemName = (EditText) findViewById(R.id.etItemName);
      final TextView tvTitle = (TextView) findViewById(R.id.tvTitle);
      final ListView lvCheckList = (ListView) findViewById(R.id.lvCheckLists);
  
      Bundle extras = getIntent().getExtras();
      if (extras != null) {
          String selectedItem = extras.getString("selectedItem");
          // get the value based on the key
          currentList = selectedItem;
      }
  
      tvTitle.setText(currentList);
  
      checkListData = getSharedPreferences(filename, 0);
      updateListView();
  
      // Button Click Listener
      bAddItem.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              String checkListStringData = etItemName.getText().toString();
              checkListData = getSharedPreferences(filename, 0);
              SharedPreferences.Editor checkListEditor = checkListData.edit();
              checkListEditor.putString(currentList + "ItemName",
                      checkListStringData);
              checkListEditor.commit();
  
              String checkListDataReturned = checkListData.getString(
                      currentList + "ItemName", currentList);
              tvTitle.setText(checkListDataReturned);
  
              updateListView();
              etItemName.setText("");
          };
      });
  }
  
  private void updateListView() {
      final ListView lvCheckList = (ListView) findViewById(R.id.lvCheckList);
      Map&lt;String, ?&gt; keys = checkListData.getAll();
  
      ArrayList&lt;String&gt; checkListStrings = new ArrayList&lt;String&gt;();
      for (Map.Entry&lt;String, ?&gt; entry : keys.entrySet()) {
          if (entry.getValue() instanceof String) {
              if (entry.getKey().equals(currentList + "ItemName")) {
                  checkListStrings.add((String) entry.getValue());
              }
          }   
                  ArrayAdapter&lt;String&gt; checkListArrayAdapter = new ArrayAdapter&lt;String&gt;(
                  this, R.layout.single_listview_item);
                  lvCheckList.setAdapter(checkListArrayAdapter);
  
      }
  
  }
  </code></pre>
  
  <p>}</p>