Click On A Textview Opens New Activity And Jumps To A Specific Id
I have an activity with a TextView that has an onClick function. After I click the TextView it should open a new activity and jump to a specific id(of e.g. another TextView) in th
Solution 1:
You can put your TextView and other elements inside a ScrollView and then you can use scrollTo(int x, int y) method of ScrollView to jump to the location of a specific element. You will need to find out the position of that specific element first.
Solution 2:
In your onCLick callback use an Intent to launch a new Activity. If necessary use the putExtra method on the Intent to add additional information, e.g. the TextView to "highlight".
Intent intent = newIntent(getBaseContext(), NewActivity.class);
intent.putExtra("TEXT_VIEW_ID", id);
startActivity(intent);
Then in the onCreate() method of NewActivity possibly use findViewById to get the TextView you need and then call requestFocus on it.
Solution 3:
This is what I needed:
scrollview.post(newRunnable() {
@Overridepublicvoidrun() {
scrollview.smoothScrollTo(0, some_random_view_id.getTop());
}
});
Post a Comment for "Click On A Textview Opens New Activity And Jumps To A Specific Id"