Logcat限制或错误

时间:2015-07-03 23:37:45

标签: android android-fragments logcat android-logcat

我正在创建一个包含许多按钮的片段。部分地出于懒惰,只是为了看看是否可能,我创建了几行代码来为每个按钮输出nessecary代码。然而,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个ID但停在5的R. 此外,当Log.i(“Hi”,“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 个答案:

答案 0 :(得分:1)

我认为用于记录的标签太长了。它没有很好的文档记录,但它有23个字符限制,当你超过它时,没有保证日志记录将正常工作。

The logging tag can be at most 23 characters