title: Is there a way to add two textviews to arrayadapter
body: <p>I want to use two <code>textviews</code> side by side in my <code>listview</code> and also want to perform search on them. Is there any way to do this without creating any new class? Here is what I have done so far:</p>
  
  <pre><code>public class MainActivity extends Activity {
  final String[] elename ={"Hydrogen","Helium","Lithium","Beryllium","Boron","Carbon","Nitrogen","Oxygen","Fluorine","Neon","Sodium","Magnesium","Aluminium","Silicon","Phosphorous","Sulphur","Chlorine","Argon","Potassium","Calcium","Scandium","Titanium","Vanadium","Chromium","Manganese","Iron","Cobalt","Nickel","Copper","Zinc","Gallium","Germanium","Arsenic","Selenium","Bromine","Krypton","Rubidium","Strontium","Yttrium","Zirconium","Niobium","Molybdenum","Technetium","Ruthenium","Rhodium","Palladium","Silver","Cadmium","Indium","Tin","Antimony","Tellurium","Iodine","Xenon","Caesium","Barium","Lanthanum","Cerium","Praseodymium","Neodymium","Promethium","Samarium","Europium","gadoliium","Terbium","Dysprosium","Holmium","Erbium","Thulium","Ytterbium","Lutetium","Hafnium","Tantalum","Tungsten","Rhenium","Osmium","Iridium","Platinum","Gold","Mercury","Thallium","Lead","Bismuth","Polonium","Astatine","Radon","Francium","Radium","Actinium","Thorium","Protactinium","Uranium","Neptunium","Plutonium","Americium","Curium","Berkelium","Californium","Einsteinium","Fermium","Mendelevium","Nobelium","Lawrencium","Rutherfordium","Dubnium","Seaborgium","Bohrium","Hassium","Meitnerium","Darmstadtium","Roentgenium","Copernicium","Ununtrium","Ununquadium","Ununpentium","Ununhexium","Ununseptium","Ununoctium"};
  final String[] nos = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115","116","117","118"};
  
  ArrayAdapter&lt;String&gt; adapter;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
      adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.list_item,R.id.element_name, elename);
      final EditText searchBar = (EditText) findViewById(R.id.searchbar);
      final DrawerLayout drawer = (DrawerLayout)findViewById(R.id.drawer_layout);
      final ListView navList = (ListView) findViewById(R.id.left_drawer);
      final LinearLayout linearLayout = (LinearLayout)findViewById(R.id.left_drawer_layout);
      navList.setAdapter(adapter);
  
  
      navList.setOnItemClickListener(new AdapterView.OnItemClickListener(){
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, final int pos,long id){
              //Change view according to numbers
  
              drawer.closeDrawer(linearLayout);
          }
      });
  
      //filter list view after search instantly
      searchBar.addTextChangedListener(new TextWatcher() {
  
          @Override
          public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
              // When user changed the Text
              MainActivity.this.adapter.getFilter().filter(cs);
          }
  
          @Override
          public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,int arg3) {
  
          }
  
          @Override
          public void afterTextChanged(Editable s) {
          }
      });
  
      //hide the keyboard after search on touch list view
      navList.setOnScrollListener(new AbsListView.OnScrollListener() {
          public void onScrollStateChanged(AbsListView view, int scrollState) {
              //hide keyboard
              InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.hideSoftInputFromWindow(navList.getWindowToken(), 0);
          }
  
          public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
          }
      });
  
      navList.setEmptyView(findViewById(R.id.empty));
  
    }
  }
  </code></pre>
  
  <p>The line:</p>
  
  <pre><code>adapter = new ArrayAdapter&lt;String&gt;this,R.layout.list_item,R.id.element_name,elename); 
  </code></pre>
  
  <p>assign the value of <code>final String[] elename</code> to a <code>textview</code> in my layout. So, is there any way to add one more <code>textview</code> and assign it the value of <code>final String[] nos</code> in the same line or without having to make a new class?.</p>
  
  <p>Sorry if this is a dumb question but I am a beginner!</p>
  
  <p>EDIT: Crash logcat</p>
  
  <pre><code>java.lang.NullPointerException
      at com.example.navigationdrawer.CustomAdapter.getView(CustomAdapter.java:34)
      at android.widget.AbsListView.obtainView(AbsListView.java:1592)
      at android.widget.ListView.makeAndAddView(ListView.java:1782)
      at android.widget.ListView.fillDown(ListView.java:705)
      at android.widget.ListView.fillFromTop(ListView.java:762)
      at android.widget.ListView.layoutChildren(ListView.java:1633)
      at android.widget.AbsListView.onLayout(AbsListView.java:1422)
      at android.view.View.layout(View.java:7175)
      at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254)
      at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130)
      at android.widget.LinearLayout.onLayout(LinearLayout.java:1047)
      at android.view.View.layout(View.java:7175)
      at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:702)
      at android.view.View.layout(View.java:7175)
      at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      at android.view.View.layout(View.java:7175)
      at android.widget.FrameLayout.onLayout(FrameLayout.java:338)
      at android.view.View.layout(View.java:7175)
      at android.view.ViewRoot.performTraversals(ViewRoot.java:1146)
      at android.view.ViewRoot.handleMessage(ViewRoot.java:1865)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:130)
      at android.app.ActivityThread.main(ActivityThread.java:3687)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:507)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
      at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>EDIT: MainActivity Crash</p>
  
  <pre><code>java.lang.NullPointerException
      at com.Chinmay.navigationdrawer.MainActivity$2.onTextChanged(MainActivity.java:66)
      at android.widget.TextView.sendOnTextChanged(TextView.java:6584)
      at android.widget.TextView.handleTextChanged(TextView.java:6631)
      at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:6775)
      at android.text.SpannableStringBuilder.sendTextChange(SpannableStringBuilder.java:889)
      at android.text.SpannableStringBuilder.change(SpannableStringBuilder.java:352)
      at android.text.SpannableStringBuilder.change(SpannableStringBuilder.java:269)
      at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:432)
      at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:409)
      at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:28)
      at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:654)
      at android.view.inputmethod.BaseInputConnection.setComposingText(BaseInputConnection.java:415)
      at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:328)
      at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:79)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:130)
      at android.app.ActivityThread.main(ActivityThread.java:3687)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:507)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
      at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>New updated Mainactivity:</p>
  
  <pre><code>public class MainActivity extends Activity {
  final String[] elename ={"Hydrogen","Helium","Lithium","Beryllium","Boron","Carbon","Nitrogen","Oxygen","Fluorine","Neon","Sodium","Magnesium","Aluminium","Silicon","Phosphorous","Sulphur","Chlorine","Argon","Potassium","Calcium","Scandium","Titanium","Vanadium","Chromium","Manganese","Iron","Cobalt","Nickel","Copper","Zinc","Gallium","Germanium","Arsenic","Selenium","Bromine","Krypton","Rubidium","Strontium","Yttrium","Zirconium","Niobium","Molybdenum","Technetium","Ruthenium","Rhodium","Palladium","Silver","Cadmium","Indium","Tin","Antimony","Tellurium","Iodine","Xenon","Caesium","Barium","Lanthanum","Cerium","Praseodymium","Neodymium","Promethium","Samarium","Europium","Gadolinium","Terbium","Dysprosium","Holmium","Erbium","Thulium","Ytterbium","Lutetium","Hafnium","Tantalum","Tungsten","Rhenium","Osmium","Iridium","Platinum","Gold","Mercury","Thallium","Lead","Bismuth","Polonium","Astatine","Radon","Francium","Radium","Actinium","Thorium","Protactinium","Uranium","Neptunium","Plutonium","Americium","Curium","Berkelium","Californium","Einsteinium","Fermium","Mendelevium","Nobelium","Lawrencium","Rutherfordium","Dubnium","Seaborgium","Bohrium","Hassium","Meitnerium","Darmstadtium","Roentgenium","Copernicium","Ununtrium","Ununquadium","Ununpentium","Ununhexium","Ununseptium","Ununoctium"};
  final String[] nos = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","60","61","62","63","64","65","66","67","68","69","70","71","72","73","74","75","76","77","78","79","80","81","82","83","84","85","86","87","88","89","90","91","92","93","94","95","96","97","98","99","100","101","102","103","104","105","106","107","108","109","110","111","112","113","114","115","116","117","118"};
  CustomAdapter cus;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      final EditText searchBar = (EditText) findViewById(R.id.searchbar);
      final DrawerLayout drawer = (DrawerLayout)findViewById(R.id.drawer_layout);
      final ListView navList = (ListView) findViewById(R.id.left_drawer);
      final LinearLayout linearLayout = (LinearLayout)findViewById(R.id.left_drawer_layout);
      CustomAdapter cus = new CustomAdapter(MainActivity.this,elename,nos);
      navList.setAdapter(cus);
  
  
      navList.setOnItemClickListener(new AdapterView.OnItemClickListener(){
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, final int pos,long id){
              //Change view according to numbers
  
              drawer.closeDrawer(linearLayout);
          }
      });
  
      //filter list view after search instantly
      searchBar.addTextChangedListener(new TextWatcher() {
  
          @Override
          public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
              // When user changed the Text
              MainActivity.this.cus.getFilter().filter(cs);
          }
  
          @Override
          public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,int arg3) {
  
          }
  
          @Override
          public void afterTextChanged(Editable s) {
          }
      });
  
      //hide the keyboard after search on touch list view
      navList.setOnScrollListener(new AbsListView.OnScrollListener() {
          public void onScrollStateChanged(AbsListView view, int scrollState) {
              //hide keyboard
              InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
              imm.hideSoftInputFromWindow(navList.getWindowToken(), 0);
          }
  
          public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
          }
      });
  
      navList.setEmptyView(findViewById(R.id.empty));
  
  }
  }
  </code></pre>