Android Open Source - Hash-Tags-Android Hash Tag Activity






From Project

Back to project page Hash-Tags-Android.

License

The source code is released under:

MIT License

If you think the Android project Hash-Tags-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Main Page showing hash tag text.//from   w  ww .  ja  v a 2s.  c o  m
 * 
 *  @auther Ramesh M Nair
 * 
 * */

package com.hashtagandroid;

import android.app.Activity;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.TextView.BufferType;
import android.widget.Toast;

import com.hashtagandroid.interfaces.TagClick;

public class HashTagActivity extends Activity implements TagClick {

  TextView mHashTagTextView, mHashTagTextViewTwo;

  TagSelectingTextview mTagSelectingTextview;

  String hastTagColorBlue = "#5BCFF2", hastTagColorRed = "#FF0000",
      hastTagColorYellow = "#FFFF00", hastTagColorGreen = "#014a01",
      testText, currentHashTagColor;

  public static int hashTagHyperLinkEnabled = 1;
  public static int hashTagHyperLinkDisabled = 0;
  int tempHyperlinkStatus;

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

    mTagSelectingTextview = new TagSelectingTextview();// TagSelectingTextview
                              // for
                              // showing tag
                              // without underline

    mHashTagTextView = (TextView) findViewById(R.id.hashtag_textview);
    CheckBox chkIos = (CheckBox) findViewById(R.id.checkBox1);

    testText = getResources().getString(R.string.test_word);

    mHashTagTextView.setMovementMethod(LinkMovementMethod.getInstance());

    // Initially we are setting hash tag color as blue and without
    // underlines to the hash tags
    setHashTag(hastTagColorBlue, hashTagHyperLinkDisabled);

    // Enable or Disable unbeline to a hash Tags

    chkIos.setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View v) {
        // is chkIos checked?
        if (((CheckBox) v).isChecked()) {
          setHashTag(currentHashTagColor, hashTagHyperLinkEnabled);
        } else {
          setHashTag(currentHashTagColor, hashTagHyperLinkDisabled);

        }

      }
    });

  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }

  public void red(View v) {
    // TODO Auto-generated method stub
    setHashTag(hastTagColorRed, tempHyperlinkStatus);
  }

  public void blue(View v) {
    // TODO Auto-generated method stub
    setHashTag(hastTagColorBlue, tempHyperlinkStatus);
  }

  public void green(View v) {
    // TODO Auto-generated method stub
    setHashTag(hastTagColorGreen, tempHyperlinkStatus);
  }

  public void yellow(View v) {
    // TODO Auto-generated method stub
    setHashTag(hastTagColorYellow, tempHyperlinkStatus);
  }

  @Override
  public void clickedTag(String tag) {
    // TODO Auto-generated method stub

    Toast.makeText(getApplicationContext(),
        "You have clicked on hash tag " + tag, 1).show();

  }

  public void setHashTag(String hashtagColor, int mhyperlickStatus) {
    /*
     * Temp color code and undelinestatus used for showing Example
     */
    currentHashTagColor = hashtagColor;
    tempHyperlinkStatus = mhyperlickStatus;

    /*
     * Main Section where we set the hash tag for the textview
     */
    mHashTagTextView.setText(mTagSelectingTextview.addClickablePart(
        testText, this, mhyperlickStatus, hashtagColor),
        BufferType.SPANNABLE);
  }

}




Java Source Code List

com.hashtagandroid.HashTagActivity.java
com.hashtagandroid.ListViewHashTag.java
com.hashtagandroid.MainActivity.java
com.hashtagandroid.TagSelectingTextview.java
com.hashtagandroid.adaptors.HashTagAdaptor.java
com.hashtagandroid.interfaces.TagClick.java