2015-07-03 3 views
0

Я создаю фрагмент со многими кнопками. Частично из лени и просто чтобы убедиться, что это возможно, я создал несколько строк кода для вывода незавершенного кода для каждой кнопки onclick. Однако логарифм не дает проблем в достижении этого.Ограничения Logcat или ошибка

код:

public class practiceFinishFragment extends Fragment implements View.OnClickListener { 

    String idss = ""; 
    TextView textView; 
    @Nullable 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
     View v = inflater.inflate(R.layout.practice_finished_fragment, container, false); 
     LinearLayout layout = (LinearLayout) v.findViewById(R.id.finishedLayout); 
     textView = (TextView) v.findViewById(R.id.textView3); 
for(int i = 0; layout.getChildCount() > i; i++){ 
      if(layout.getChildAt(i) instanceof Button){ 
       layout.getChildAt(i).setOnClickListener(this); 
       String ids = layout.getChildAt(i).getResources().getResourceEntryName(layout.getChildAt(i).getId()); 

idss = idss + "\n" + "case: "+ "R.id." +ids; 
       //Log.i(idss, ""); 
      } 
     } 
     Log.i(idss, ""); 
     textView.setText(idss); 

     return v; 
    } 

    @Override 
    public void onClick(View view) { 
     Log.i("HI", "Hey"); 
     switch (view.getId()){ 
     case R.id.playAgain: 
      Log.i(idss, ""); 
      // Log.i("HI", "He"); 
      //case 

     } 

    } 
} 

XML

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center_horizontal" 
android:id="@+id/finishedLayout" 
    > 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:textSize="32sp" 
     android:layout_marginTop="50dp" 
     android:text="Good Job You Got \n X out of Y \n Questions Correct" 
     android:gravity="center" 
     android:id="@+id/textView3" 
     android:layout_gravity="center" 

     /> 
    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Play Again" 
     android:id="@+id/playAgain" 
     /> 
    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Return to Start" 
     android:id="@+id/returnStart" 
     /> 
    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Share Your Score" 
     android:id="@+id/shareScore" 
     /> 
    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Go over Missed" 
     android:id="@+id/retry" 
     /> 
    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Review Statistics" 
     android:id="@+id/scoreStatistics" 
     /> 
    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Change Preferences" 
     android:id="@+id/changePrefrences" 
     /> 

</LinearLayout> 

возвращает первые 4 идентификаторами, но останавливается на R. из 5. Также, когда Log.i ("Привет", " HEY ") удаляется, он ничего не распечатывает. Любая помощь в выяснении того, что в мире происходит в этом, будет большой помощью.

case: R.id.playAgain 
    case: R.id.returnStart 
    case: R.id.shareScore 
    case: R.id.retry 
    case: R. at[ 07-03 19:31:14.715 755: 867 E/WifiStateMachine ] 
    [1,435,966,274,715 ms] noteScanEnd WorkSource{10011} onTime=0 

ответ

1

Я думаю, что ваш тег, используемый для регистрации, слишком длинный. Он плохо документирован, но имеет ограничение на 23 символа, и нет никаких записей о гарантированном доступе, если вы его превысите.

The logging tag can be at most 23 characters

+0

Да, это то, что изначально считалось. Однако я помещаю тег в текстовый редактор и его 104 символа, поэтому кажется, что этот предел больше не верен, но, возможно, существует новый предел. –