onclick on textview迟到了回应

时间:2014-11-30 11:08:39

标签: android android-layout android-intent android-activity

我有一个onclick函数文本视图,但需要3到4秒才能响应。

与TextView相关的布局代码:

<TableRow ... >
<TextView
    android:id="@+id/questionReportSelectTV"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="15dip"
    android:paddingTop="15dip"
    android:clickable="true"
    android:onClick="showImageActivity"
    android:textSize="17sp" />

</TableRow>

夸大布局:

LayoutInflater inflaterQuestion = getLayoutInflater(); 
TableRow trQuestion= (TableRow) inflaterQuestion.inflate(R.layout.questionreportrow, setTaleLayout, false); 
LayoutInflater inflaterSpace = getLayoutInflater(); 
TableRow trSpace = (TableRow) inflaterSpace.inflate(R.layout.space_tablerow, setTaleLayout, false);
TextView questionDisplay = (TextView)trQuestion.findViewById(R.id.questionReportSelectTV); 
questionDisplay.setTypeface(typeFace); 
questionDisplay.setText(pn); 
questionDisplay.setTag(counterPosition);

点击按钮时的操作:

public void showImageActivity(View view){ 
   int tvTag = (Integer) view.getTag(); 
   Intent imageIntent = new Intent(ReportExamSelectQuestionActivity.this, DisplayImageActivity.class);
   imageIntent.putExtra("POSITION", tvTag); 
   startActivity(imageIntent); 
}

1 个答案:

答案 0 :(得分:0)

您的TextView是正常的。也许在showImageActivity函数中有一些错误,需要时间来响应。

作为测试,在函数的第一行显示toast以检查响应延迟。

package com.example.test;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import android.app.Activity;

public class Activity1 extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity1_layout);
}

public void showImageActivity(View v)
{
    Toast.makeText(getApplicationContext(), "Clicked", Toast.LENGTH_SHORT).show();
    // Here write your codes about Showing image...
}
}