Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(convertView == null){
- convertView = lInflater.inflate(R.layout.listview, null);
- holder = new ViewHolder();
- holder.text2 = (TextView)convertView.findViewById(R.id.TextView02);
- convertView.setTag(holder);
- }
- else{
- holder = (ViewHolder)convertView.getTag();
- }
- holder.text2.setText(arr2[position]);
- holder.text2.invalidate();
- int lineCnt = holder.text2.getLineCount();
- static class ViewHolder{
- TextView text2;
- }
- holder.text2.setText(arr2[position]);
- holder.text2.post(new Runnable() {
- @Override
- public void run() {
- int lineCnt = holder.text2.getLineCount();
- // Perform any actions you want based on the line count here.
- }
- });
- textView.post(new Runnable() {
- @Override
- public void run() {
- Log.v("Line count: ", textView.getLineCount()+"");
- }
- });
- yourTextView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
- @Override
- public void onGlobalLayout() {
- if (yourTextView.getLineCount() > 1) {
- mediaAtomLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
- }
- }
- });
- protected void onCreate(final Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- new myAsyncTask().execute(null, null, null);
- }
- private class myAsyncTask extends AsyncTask<Void, Void, Void> {
- @Override
- protected Void doInBackground(final Void... params) {
- // It's okay to leave this as it is
- return null;
- }
- @Override
- protected void onPostExecute(final Void result) {
- super.onPostExecute(result);
- //DO YOUR TASK HERE, getLineCount(), etc.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement