2012-02-27 2 views
1

私は、TextViewとEdittextが隣り合っている私のアクティビティのリストビューから離れようとしています。リストビューのEdittextは私のスクロールビューをリストビューのように見せかけるようにしようとしていますが、リサイクルの問題はありませんでした。私は(私はそれが見えるようにしたいものを100%ではない)開始するレイアウトをセットアップしましたが、今私はデータベースから引っ張られたデータで私のtextviewを設定したいと私はここに壁を打っています。ここで私は私がこれを行う方法上の任意の良いリソースを見つけることができなかった私は、これまで...リストビューのように動作するビューをスクロールし、データベースからテキストビューを設定します。

public class inputpage extends Activity { 
    public static int editCount = 10; //needs to be dynamic based on how many items the cursor pulls but using 10 till I have more code in place 
    public LinearLayout editlayout; 
    static Map<Integer, String> inputValues = new LinkedHashMap<Integer, String>(); 
    @Override 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.inputlayout); 
    editlayout=(LinearLayout) this.findViewById(R.id.editlayout); 

    buildRow(); 



} 

    public void buildRow(){ 
     LayoutParams textparam = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 
     LayoutParams editparam = new LayoutParams(350, LayoutParams.WRAP_CONTENT); 
     textparam.setMargins(2, 2, 2, 2); 

     for (int i = 0; i < editCount; i++){ 
      //textview 
      TextView tv=new TextView(this); 
      tv.setLayoutParams(textparam); 
      tv.setText("test"); 
      tv.setTextSize(35); 
      tv.setTextColor(getResources().getColor(R.color.black)); 
      this.editlayout.addView(tv); 
      //edittext 
      EditText edit = new EditText(this); 
      edit.setLayoutParams(editparam); 
      this.editlayout.addView(edit); 
      edit.setId(editCount); 
      edit.addTextChangedListener(new TextWatcher(){ 
      public void afterTextChanged(Editable editable) { 
       Log.e(String.valueOf(editCount), "Position in array"); 
       inputValues.put(editCount, editable.toString()); 
       Log.e(editable.toString(), "added to array"); 

      } 
      public void beforeTextChanged(CharSequence s, int start, int count, 
        int after) { 
       // TODO Auto-generated method stub 

      } 
      public void onTextChanged(CharSequence s, int start, int before, 
        int count) { 
       // TODO Auto-generated method stub 

      } 
     }); 

     }} 
} 

私が前である....

public class editpage extends ListActivity { 
    private dbadapter mydbhelper; 
    private PopupWindow pw; 
    public static SimpleCursorAdapter editadapter; 
    public static ArrayList<String> editTextList = new ArrayList<String>(); 
    private ArrayList<EditText> m_edit = new ArrayList<EditText>(); 
    public static Map<Integer,String> myList=new LinkedHashMap<Integer,String>(); 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.edit_list); 
     m_edit.clear(); 
     mydbhelper = new dbadapter(this); 
     mydbhelper.open(); 
     fillData(); 

     } 

    } 
    //size of adapter and arrays 
    public static int getCount(){ 
     return editadapter.getCount(); 
    } 

    public void fillData() { 
    Cursor e = mydbhelper.getUserWord(); 
     startManagingCursor(e); 
     String[] from = new String[] {dbadapter.KEY_USERWORD,}; 
     int[] to = new int[] {R.id.textType,}; 
     editadapter = new SimpleCursorAdapter(this, R.layout.edit_row, e, from, to); 
     ListView list = getListView(); 
     View footer = getLayoutInflater().inflate(R.layout.footer_layout, list, false); 
     list.addFooterView(footer); 
     setListAdapter(editadapter);} 

       } 

を使用していたコードを持っているものですここの誰かが私が構築できるリンクやモックコードを知っていることを願っています。

答えて

0

私はしばらく私を連れて行きましたが、私はそれを得ました。他の誰かがこの情報を必要とした場合にポストすると思ったので、正しい方向に進むためにヒントを探していました。私が必要とするレイアウトに近いものを得るために、私はtablelayoutに変更しました。

public class inputpage extends Activity { 

    public TableLayout tl; 
    static Map<Integer, String> inputValues = new LinkedHashMap<Integer, String>(); 
    private dbadapter mydbhelper; 
    public static int editCount; 
    public Cursor cursor; 

    @Override 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 
    mydbhelper = new dbadapter(this); 
    mydbhelper.open(); 
    setContentView(R.layout.tablelayout); 
    tl=(TableLayout) this.findViewById(R.id.table); 
    cursor = mydbhelper.getUserWord(); 
    editCount = cursor.getCount(); 
    buildRow(); 






    } 
    public void buildRow(){ 

     LayoutParams textparam = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT); 
     LayoutParams editparam = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT); 
     textparam.setMargins(2, 2, 2, 2); 
     LayoutParams rowparam = new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT); 
     cursor.moveToFirst(); 
     for (int i = 0; i < editCount; i++){ 
      TableRow tr = new TableRow(this); 
      tr.setLayoutParams(rowparam); 

      //textview 
      TextView tv=new TextView(this); 
      tv.setLayoutParams(textparam); 
      tv.setText(cursor.getString(cursor.getColumnIndex("userword"))); 
      tv.setTextSize(35); 
      tv.setGravity(Gravity.CENTER); 
      tv.setTextColor(getResources().getColor(R.color.black)); 
      tr.addView(tv); 

      //edittext 
      EditText edit = new EditText(this); 
      edit.setLayoutParams(editparam); 
      tr.addView(edit); 
      edit.setId(editCount); 
      edit.addTextChangedListener(new TextWatcher(){ 
      public void afterTextChanged(Editable editable) { 
       //unfinished and confirmed to work atm 
          Log.e(String.valueOf(editCount), "Position in array"); 
       inputValues.put(editCount, editable.toString()); 
       Log.e(editable.toString(), "added to array"); 


      } 
      public void beforeTextChanged(CharSequence s, int start, int count, 
        int after) { 
       // TODO Auto-generated method stub 

      } 
      public void onTextChanged(CharSequence s, int start, int before, 
        int count) { 
       // TODO Auto-generated method stub 

      } 
     }); 
      cursor.moveToNext(); 
      tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT)); 
     }} 

} 
関連する問題