Я работаю на андроид проектаМой метод по методу события OnClick ничего
не делать Создание метода на
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)
Вот мой файл макета; кажется, что метод (диагноз (View View)) не вызван. Мой метод диагностики() определен в 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)', с нижним регистром. –
Пробовал и до сих пор не работает – Mike
Как насчет 'public void diagnose (View v)'? –