Despite the fact that I managed to create marquee TextView, because I followed the textbook, and it works correctly, when I tried to do another one TextViewin another activity like marquee, it did not work. I took the exact step accurately, but to no avail. what do you think I'm missing?
Update
I think the problem is the focuspresentation, because I checked if it has TextViewfocus even after the call imgPathTv.setSelected(true), and as a result, it has no focus.
Updated_Code
String imgPath = dataBaseRow.getImgPath();
if (imgPath.equals("")) {
Log.d(TAG, "@createInfoReport(): dataBaseRow.getImgPath() Returns NULL");
imgPathTv.setText("NULL");
}else {
Log.d(TAG, "@createInfoReport(): dataBaseRow.getImgPath() Has Value");
imgPathTv.setSelected(true);
imgPathTv.setText(imgPath);
if(imgPathTv.findFocus() != null) {
Toast.makeText(getApplicationContext(), "there is a View has the Focus", Toast.LENGTH_SHORT).show();
}else
Toast.makeText(getApplicationContext(), "NO View has the Focus", Toast.LENGTH_SHORT).show();
}
Java_Code:
TextView imgPathTv = (TextView) mDialog.findViewById(R.id.imgPathValue);
Log.i(TAG, "@createInfoReport(): imgPathTv IS IN FOCUS");
imgPathTv.setSelected(true);
TextView_xml:
<TextView
android:id="@+id/imgPathValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:fadingEdge="horizontal"/>
source
share