Search Results

Search found 6 results on 1 pages for 'tiandong'.

Page 1/1 | 1 

  • Android ListView: getTag() returns null

    - by TianDong
    Hallo all, I have a ListView which contains a Button in each line. The following code is part of the getView() Method public View getView(final int position, View convertView, ViewGroup parent) { View row = convertView; TextView tv; Button saveA_button; EditText edittext; FITB_ViewWrapper wrapper; if (row == null) { LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (ChooseMode_Act.modeInfo.equalsIgnoreCase("Training")) { row = li.inflate(R.layout.exercise_for_training_fitb,parent, false); }else { row = li.inflate(R.layout.exercise_for_exam_fitb,parent, false); } wrapper=new FITB_ViewWrapper(row); row.setTag(wrapper); if (ChooseMode_Act.modeInfo.equalsIgnoreCase("Exam")) { saveA_button=wrapper.getSaveAnswer_Button(); OnClickListener l=new OnClickListener() { @Override public void onClick(View v) { Integer mp=(Integer)v.getTag(); Log.i("mp","my Position is: "+mp); } }; saveA_button.setOnClickListener(l); } }else { wrapper=(FITB_ViewWrapper) row.getTag(); } For my App i need to known to which item the Button belongs to, so i try to detect it. The code Log.i("mp","my Position is: "+mp); puts out a message: mp myPosition is: null I can't understand, why do i get a "null" but not an Integer? How can i find out the Position of an Item in a ListView? Thanks a lot.

    Read the article

  • Android: How to make RadioGroup work correctly in a ListView?

    - by TianDong
    Hello! I have a ListView, which has a TextView and a RadioGroup with 4 RadioButtons as Children in each row. Now i can select a RadioButton in each row. But if i scroll the ListView, my Selection is gone or it does not showed correctly. For example, i choose the RadioButton A in the first row, if i scroll through the ListView and then go back to the first row again, either none of the RadioButtons in the RadioGroup is checked or RadioButton C is checked instead of A. How can i fix this Problem? I have tried 7 days already, but still i find no solution. Can anybody help me? I'll be very appriciate of that.

    Read the article

  • Android: How to read a txt file which contains Chinese characters?

    - by TianDong
    Hallo, i have a txt file which contains many chinese characters, and the txt file is in the directory res/raw/test.txt. I want to read the file but somehow i can't make the chinese characters displayed correctly. Here is my code: try { InputStream inputstream = getResources().openRawResource(R.raw.test); BufferedReader bReader = new BufferedReader(new InputStreamReader(inputstream,Charset.forName("UTF-8"))); String line = null; while ((line= bReader.readLine())!= null) { Log.i("lolo", line); System.out.println("here is some chinese character ???????"); } } catch (IOException e) { e.printStackTrace(); } Both Log.i("lolo", line); and System.out.println("here is some chinese character ???????") don't show characters correctly, i can not even see the chinese characters in the println() method. What can i do to fix this problem? Can anybody help me?

    Read the article

  • How to make a EditText work correctly in a ListView?

    - by TianDong
    Hallo all, I have a ListView, which contains an EditText in each of it's row. I also have an Array.The length of the Array==the Nr of the rows in the ListView. I want to store the user input (the text in the EditText) to the Arrray. E.g, if i type some text in the EditText in the first row of the ListView, i want the text to be stored in Array[0]. But how can i detect to which row the EditText belongs to? I can detect the possition of the row if the row contains a RadioGroup, but not a EditText. What if i first type some text in the EditText and sometime later i want to update mein Input? How can i update it? Thanks a lot!

    Read the article

  • SQLite: 2 Problems by working with table

    - by TianDong
    Hallo all, I have a SQliteDatabase object db, i want to create a table in db with the following code db.execSQL("CREATE TABLE IF NOT EXISTS "+ TABLE2_NAME + " (exer_nr INTEGER PRIMARY KEY ,exerText varchar(250),answerA varchar(250),answerB varchar(250),answerC varchar(250),answerD varchar(250))"); An Error occur. Why? Is this too large? How can i fix it? Another problem: I want to insert a row into the table, whose "exerText" column contains the following code as part of it's content. main( ) { int m=12, n=34; printf("%d%d", m+ +,+ +n); printf("%d%d\n",n+ +,+ +m); } An Error occur because of the "" and '' symbols in the code. How can i fix this problem ? Thanks a lot

    Read the article

1