【发布时间】:2015-11-27 18:51:50
【问题描述】:
我正在做一个安卓项目
-
在
MainActivity上创建一个方法,如下所示:public void diagnose(View View) { System.out.println("%%%%%%%%%%%%%%%%% INSIDE DIAGNOSE %%%%%%%%%%%%%%"); String PTCondition = " "; int row, col, count, percentageOfLikelihood, maxPercent = 0; //To store the name of each condition and its percentage of likelihood String[][] percentPerCondition = new String[8][]; percentPerCondition[0][0] = "Rotator Cuff Strain"; percentPerCondition[1][0] = "Coracoid Impingement"; percentPerCondition[2][0] = "Supraspinatus Impingement"; percentPerCondition[3][0] = "Bicipital Tendonitis"; percentPerCondition[4][0] = "Glenohumeral Dislcation"; percentPerCondition[5][0] = "Clavicular Fracture"; percentPerCondition[6][0] = "Labral Tear"; percentPerCondition[7][0] = "SubAcromial Bursitis"; //Store binary sequence of Special Tests that correspond to the conditions above int[][] STValuesPercondition = new int[][] { { 1, 0, 1, 0, 1 }, { 0, 1, 0, 1, 1 }, { 0, 1, 1, 0, 0 }, { 1, 1, 0, 0, 1 }, { 0, 0, 1, 1, 1 }, { 1, 1, 0, 1, 0 }, { 1, 0, 1, 1, 0 }, { 0, 1, 1, 1, 0 } }; //Compare the binary sequence in PTFindings to all conditions for (row = 0; row < STValuesPercondition.length; row++) { count = 0; for (col = 0; col < STValuesPercondition.length; col++) { if (STValuesPercondition[row][col] == PTFindings[row]) count++; } //Calculate percentage of likelihood percentageOfLikelihood = (count / 5) * 100; if (percentageOfLikelihood > maxPercent) { maxPercent = percentageOfLikelihood; PTCondition = percentPerCondition[row][0]; } System.out.println("&&&&&&& Inside diagnosis: " + PTCondition); //Store percentage as a String in the percentPerCondition 2D array; may need it later percentPerCondition[row][1] = Integer.toString(percentageOfLikelihood); } //Point to the TextView where data to be displayed - in layout file (displaydx) DxTextView = (TextView) findViewById(R.id.dx1); //Populate the textView with the data from DxTextView.setText(PTCondition); //Display the PTCondition on the activity String passPTCondition = ""; Intent i = new Intent(getApplicationContext(), DisplayDxActivity.class); i.putExtra(passPTCondition, PTCondition); startActivity(i); } //public void diagnose(View View) -
这是我的布局文件;似乎没有调用该方法( diagnostic(View View) )。我的 diagnostic() 方法在 onCreate() 中定义 当我点击诊断时没有任何反应? !!!!
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Generate Possible Diagnoses" android:id="@+id/SubmitButton" android:textColor="#ffff6949" android:background="#ffffffff" android:textStyle="bold" android:onClick="diagnose" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:id="@+id/dx1" android:layout_gravity="center_horizontal" />
【问题讨论】:
-
尝试
public void diagnose(View view),使用小写视图。 -
试过了还是不行
-
public void diagnose(View v)怎么样? -
还是不行;它不执行这一行: System.out.println("%%%%%%%%%%%%%%%% INSIDE DIAGNOSE %%%%%%%%%%%%%");我假设它甚至不调用诊断()
-
这个答案有帮助吗? stackoverflow.com/questions/15512965/…