I figured out a solution that worked for me from the comments..
So i have placed an edit text behind my imageview like this
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >
<ImageView
android:id="@+id/helpIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/help" />
<EditText
android:id="@+id/helpMsg"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:enabled="false"
android:hint=""
android:inputType="none" />
</RelativeLayout>
then on onClick event of the imageview
helpIcon.setOnClickListener(new OnClickListener() {
//use this variable only if you want to remove the toast before it automatically disappears
private boolean isToastVisible = false;
@Override
public void onClick(View arg0) {
if (!isToastVisible) {
helpMessage.requestFocus();
helpMessage.setError(getResources().getString(R.string.helpText));
isToastVisible = true;
new CountDownTimer(5000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
}
@Override
public void onFinish() {
helpMessage.setError(null);
isToastVisible = false;
}
}.start();
}
else {
helpMessage.setError(null);
isToastVisible = false;
}
}
});