Need to Override Specific Row in custom Static ListView

onlinedesi

New Member
So here's basically the deal: I am working on a menu list for an app I am making. The list data is static. I followed this tutorial for creating it (changing values as needed) - http://www.ezzylearning.com/tutorial.aspx?tid=1763429.Now my list isn't super complex. It's going to have the same data every time. There are only two sections. Currently everything works but... I need to basically insert or replace a row with the header view for that section. The index for the row I set up in my code to be replace will not change (unless I add more menu entries for the first section, in which case I can just update the index as needed).That is the code behind the main activity. At present, the row I need to override is the 7th one (hence ("replace, replace")). I need to change the view to a new layout view that already has the title in it and everything. The other code isMain Activity:\[code\]import android.app.Activity;import android.os.Bundle;import android.widget.ListView;public class HU_main extends Activity { private ListView f_menu; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.hu_main); Front_menu front_menu_data[] = new Front_menu[] { new Front_menu("Cadences", "Reference chart of all the primary cadences."), new Front_menu("Chords and Non-Chord Tones", "Reference chart of chord types and non-chord tones and associated rules of NCTs."), new Front_menu("Key Signatures", "Reference chart for key signature rules."), new Front_menu("Scale/Mode Triads", "List of triads and degrees for all standard diatonic scale modes."), new Front_menu("Harmonic Progression", "Reference chart for scale and mode chord progressions."), new Front_menu("Terminology Translation", "Reference list if primary music terms and instruments in German, Italian and French."), new Front_menu("Replace", "Replace"), new Front_menu("Chord Finder", "Enter notes to find chords."), new Front_menu("Modulation", "Reference chart of chord types and non-chord tones and associated rules of NCTs."), new Front_menu("Scale Finder", "Find scales and modes by notes."), new Front_menu("Transposition", "Show changes to and from concert pitch for transposing instruments or determine overall transposition of key.") }; Front_menuAdapter adapter = new Front_menuAdapter(this, R.layout.item_layout, front_menu_data); f_menu = (ListView)findViewById(R.id.f_menu); f_menu.setAdapter(adapter); } }\[/code\]Front_menuAdapter:\[code\]import android.app.Activity;import android.content.Context;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ArrayAdapter;import android.widget.TextView;public class Front_menuAdapter extends ArrayAdapter<Front_menu>{ Context context; int layoutResourceId; Front_menu data[] = null; public Front_menuAdapter(Context context, int layoutResourceId, Front_menu[] data) { super(context, layoutResourceId, data); this.layoutResourceId = layoutResourceId; this.context = context; this.data = http://stackoverflow.com/questions/15858284/data; } @Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; Front_menuHolder holder = null; if(row == null) { LayoutInflater inflater = ((Activity)context).getLayoutInflater(); row = inflater.inflate(layoutResourceId, parent, false); holder = new Front_menuHolder(); holder.txtTitle1 = (TextView)row.findViewById(R.id.menu_item); holder.txtTitle2 = (TextView)row.findViewById(R.id.item_description); row.setTag(holder); } else { holder = (Front_menuHolder)row.getTag(); } Front_menu front_menu = data[position]; holder.txtTitle1.setText(front_menu.item); holder.txtTitle2.setText(front_menu.desc); return row; } class Front_menuHolder { TextView txtTitle1; TextView txtTitle2; }}\[/code\]Front_menu (constructor):\[code\]public class Front_menu { public String item; public String desc; public Front_menu() { super(); } public Front_menu(String item, String desc) { super(); this.item = item; this.desc = desc; }}\[/code\]
 
Top