下面列出了android.widget.TextView#setOnTouchListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@SuppressLint("ClickableViewAccessibility")
private void configureText(final TextView text) {
text.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
text.setMaxLines(5);
break;
case MotionEvent.ACTION_UP:
text.setMaxLines(1);
break;
}
return true;
}
});
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Bundle args = getArguments();
TextView mHighlightText = view.findViewById(R.id.text_view_highlight_text);
mHighlightText.setOnTouchListener(new MovingTouchListener(getDialog().getWindow()));
String title = args.getString(HIGHLIGHT_TEXT_KEY, "TEXT");
mHighlightText.setText(title);
int highlightColor = args.getInt(HIGHLIGHT_COLOR_KEY);
mHighlightText.setBackgroundColor(highlightColor);
mNoteEditText = view.findViewById(R.id.toc_card_body);
String note = args.getString(HIGHLIGHT_NOTE_KEY, "");
mNoteEditText.setText(note);
int highlightDarkColor = args.getInt(HIGHLIGHT_DARK_COLOR_KEY);
mNoteEditText.setBackgroundColor(highlightDarkColor);
if (note.isEmpty()) {
// Show soft keyboard automatically and request focus to field
mNoteEditText.requestFocus();
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}
}
/**
* Set text of textView with html format of html parameter
*
* @param textView instance {@link TextView}
* @param html String
*/
@SuppressLint("ClickableViewAccessibility")
public static void setTextWithLinks(TextView textView, CharSequence html) {
textView.setText(html);
textView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
if (action == MotionEvent.ACTION_UP ||
action == MotionEvent.ACTION_DOWN) {
int x = (int) event.getX();
int y = (int) event.getY();
TextView widget = (TextView) v;
x -= widget.getTotalPaddingLeft();
y -= widget.getTotalPaddingTop();
x += widget.getScrollX();
y += widget.getScrollY();
Layout layout = widget.getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
ClickableSpan[] link = Spannable.Factory.getInstance()
.newSpannable(widget.getText())
.getSpans(off, off, ClickableSpan.class);
if (link.length != 0) {
if (action == MotionEvent.ACTION_UP) {
link[0].onClick(widget);
}
return true;
}
}
return false;
}
});
}
private void shuffleWords() {
wordsContainer.removeAllViews();
final List<String> wordList = wordBank.loadWords();
for (String w : wordList) {
final TextView wordView
= (TextView) getLayoutInflater().inflate(R.layout.word, null, true);
wordView.setText(w);
wordView.setOnTouchListener(new WordTouchListener());
wordView.setTag(w);
wordsContainer.addView(wordView);
}
Crashlytics.setInt(App.CRASHLYTICS_KEY_WORDBANK_COUNT, wordList.size());
}
protected void init(Context mContext) {
LayoutInflater iflater = LayoutInflater.from(mContext);
iflater.inflate(R.layout.common_bubble_dialog_left, this);
mTextView = (TextView) findViewById(R.id.common_bubble_left_text);
mTextView.setOnTouchListener(this);
mListDrawable = (LevelListDrawable) mTextView.getBackground();
}
public OutlineItemView(Context context) {
super(context);
View.inflate(context, R.layout.outline_item, this);
titleView = (TextView) findViewById(R.id.title);
titleView.setOnTouchListener(urlClickListener);
tagsView = (TextView) findViewById(R.id.tags);
}
@SuppressLint("ClickableViewAccessibility")
private void gridConvert(final CommonHolder holder, Bean item) {
final TextView tvHandler = holder.getView(R.id.tv_style1);
tvHandler.setText(item.content);
tvHandler.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN && getItemCount() > 1 && startDragListener != null) {
// Step 9-5: 只有调用onStartDrag才会触发拖拽 (这里在touch时开始拖拽,当然也可以单击或长按时才开始拖拽)
startDragListener.onStartDrag(holder);
return true;
}
return false;
}
});
// Step 9-7: 设置ItemTouchListener
holder.setOnItemTouchListener(new ItemTouchHelperViewHolder() {
@Override
public void onItemSelected() {
// 触发拖拽时回调
tvHandler.setBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.corner_bg_touch_select));
}
@Override
public void onItemClear() {
// 手指松开时回调
tvHandler.setBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.corner_bg_touch_normal));
}
});
}
/**
* 格式化微博或评论正文
*
* @param text 文本内容
* @param tvContent TextView
*/
public void formatContent(final boolean comment, final long id, String text, final TextView tvContent) {
SpannableStringBuilder builder;
if (comment) {
builder = mCommentContent.get(id);
} else {
builder = mTextContent.get(id);
}
if (builder != null) {
tvContent.setText(builder);
} else {
if (mStatusListener == null) {
mStatusListener = new StatusListener();
}
mAnalyzeTask = StatusAnalyzeTask.getInstance(mActivity, mStatusListener);
mAnalyzeTask.setStatusAnalyzeListener(new StatusAnalyzeListener() {
@Override
public void onSpannableStringComplete(SpannableStringBuilder ssb) {
if (comment) {
mCommentContent.put(id, ssb);
} else {
mTextContent.put(id, ssb);
}
tvContent.setText(ssb);
}
});
mAnalyzeTask.execute(text);
tvContent.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return textTouchEvent((TextView) v, event);
}
});
}
}
@Override
public View onCreateView(ViewGroup parent) {
View view = super.onCreateView(parent);
final TextView textView = (TextView) view.findViewById(android.R.id.summary);
// TODO(dullweber): Rethink how the link can be made accessible to TalkBack before launch.
// Create custom onTouch listener to be able to respond to click events inside the summary.
textView.setOnTouchListener(new View.OnTouchListener() {
@Override
@SuppressLint("ClickableViewAccessibility")
public boolean onTouch(View v, MotionEvent event) {
if (!mHasClickableSpans) {
return false;
}
// Find out which character was touched.
int offset = textView.getOffsetForPosition(event.getX(), event.getY());
// Check if this character contains a span.
Spanned text = (Spanned) textView.getText();
ClickableSpan[] types = text.getSpans(offset, offset, ClickableSpan.class);
if (types.length > 0) {
if (event.getAction() == MotionEvent.ACTION_UP) {
for (ClickableSpan type : types) {
type.onClick(textView);
}
}
return true;
} else {
return false;
}
}
});
return view;
}
public static void enableClicksOnSpans(TextView textView) {
final SpanClickHandler helper = new SpanClickHandler(textView, null);
textView.setOnTouchListener((view, event) -> {
final TextView textView1 = (TextView) view;
final Layout layout = textView1.getLayout();
if (layout != null) {
helper.layout = layout;
helper.left = textView1.getTotalPaddingLeft() + textView1.getScrollX();
helper.top = textView1.getTotalPaddingTop() + textView1.getScrollY();
return helper.handleTouchEvent(event);
}
return false;
});
}
private void inti() {
textView = (TextView) findViewById(R.id.textview);
scrollView = (ScrollView) findViewById(R.id.scroll_view);
zoomButtonsController = new ZoomButtonsController(scrollView);
textView.setOnTouchListener(zoomButtonsController);
// zoomButtonsController.setAutoDismissed(false);
zoomButtonsController.setZoomInEnabled(true);
zoomButtonsController.setZoomOutEnabled(true);
zoomButtonsController.setFocusable(true);
zoomTextSize = textView.getTextSize();
zoomButtonsController.setOnZoomListener(new ZoomButtonsController.OnZoomListener() {
@Override
public void onVisibilityChanged(boolean visible) {
}
@Override
public void onZoom(boolean zoomIn) {
if (zoomIn) {
zoomTextSize = zoomTextSize + 1.0f;
} else {
zoomTextSize = zoomTextSize - 1.0f;
}
textView.setTextSize(zoomTextSize);
}
});
}
private void shuffleWords() {
wordsContainer.removeAllViews();
final List<String> wordList = wordBank.loadWords();
for (String w : wordList) {
final TextView wordView
= (TextView) getLayoutInflater().inflate(R.layout.word, null, true);
wordView.setText(w);
wordView.setOnTouchListener(new WordTouchListener());
wordView.setTag(w);
wordsContainer.addView(wordView);
}
Crashlytics.setInt(App.CRASHLYTICS_KEY_WORDBANK_COUNT, wordList.size());
}
@Override
public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
}
try {
active = true;
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
contextWithLocale = getContextWithLocale(getApplicationContext(), getBaseContext());
//mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mInflater = LayoutInflater.from(contextWithLocale);
mView = mInflater.inflate(R.layout.view_akashi_list, null);
KcaUtils.resizeFullWidthView(getApplicationContext(), mView);
mView.setVisibility(View.GONE);
akashiview = mView.findViewById(R.id.akashiviewlayout);
akashiview.findViewById(R.id.akashiview_head).setOnTouchListener(mViewTouchListener);
akashiview_gtd = (TextView) akashiview.findViewById(R.id.akashiview_gtd);
akashiview_gtd.setOnTouchListener(mViewTouchListener);
akashiview_gtd.setText(getStringWithLocale(R.string.aa_btn_safe_state0));
akashiview_gtd.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.white));
akashiview_star = (TextView) akashiview.findViewById(R.id.akashiview_star);
akashiview_star.setText(getString(R.string.aa_btn_star0));
akashiview_star.setOnTouchListener(mViewTouchListener);
akashiview_list = (ListView) akashiview.findViewById(R.id.akashiview_list);
adapter = new KcaAkashiListViewAdpater2();
mParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT,
getWindowLayoutType(),
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
mParams.gravity = Gravity.CENTER;
mManager = (WindowManager) getSystemService(WINDOW_SERVICE);
Display display = ((WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
Point size = new Point();
display.getSize(size);
displayWidth = size.x;
} catch (Exception e) {
active = false;
error_flag = true;
//sendReport(e, 1);
stopSelf();
}
}
@SuppressWarnings("unchecked")
@Override
public View createView(Context context) {
actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR);
actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR);
// actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setBackText(context.getString(R.string.Cancel));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
} else if (id == 1) {
if (delegate != null) {
finishFragment(false);
delegate.startPhotoSelectActivity();
}
} else if (id == item_photos) {
refreshShowPic();//刷新照片目录
} else if (id == item_video) {
refreshShowVedio();//刷新录像目录
}
}
});
fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.setBackgroundColor(DarkTheme ? 0xff000000 : 0xffffffff);
//==============videos pick====================
int res = !singlePhoto && filterMimeTypes.length > 0 ? R.string.PickerVideo : R.string.Album;
actionBar.setTitle(context.getString(res));
selectedMode = filterMimeTypes.length > 0 ? 1 : selectedMode;
listView = new ListView(context);
listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4),
AndroidUtilities.dp(4));
listView.setClipToPadding(false);
listView.setHorizontalScrollBarEnabled(false);
listView.setVerticalScrollBarEnabled(false);
listView.setSelector(new ColorDrawable(0));
listView.setDividerHeight(0);
listView.setDivider(null);
listView.setDrawingCacheEnabled(false);
listView.setScrollingCacheEnabled(false);
frameLayout.addView(listView);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView
.getLayoutParams();
layoutParams.width = LayoutHelper.MATCH_PARENT;
layoutParams.height = LayoutHelper.MATCH_PARENT;
// layoutParams.bottomMargin = AndroidUtilities.dp(48);
listView.setLayoutParams(layoutParams);
listView.setAdapter(listAdapter = new ListAdapter(context));
AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);
emptyView = new TextView(context);
emptyView.setTextColor(0xff808080);
emptyView.setTextSize(20);
emptyView.setGravity(Gravity.CENTER);
emptyView.setVisibility(View.GONE);
emptyView.setText(R.string.NoPhotos);
frameLayout.addView(emptyView);
layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
layoutParams.width = LayoutHelper.MATCH_PARENT;
layoutParams.height = LayoutHelper.MATCH_PARENT;
layoutParams.bottomMargin = AndroidUtilities.dp(48);
emptyView.setLayoutParams(layoutParams);
emptyView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
progressView = new FrameLayout(context);
progressView.setVisibility(View.GONE);
frameLayout.addView(progressView);
layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
layoutParams.width = LayoutHelper.MATCH_PARENT;
layoutParams.height = LayoutHelper.MATCH_PARENT;
layoutParams.bottomMargin = AndroidUtilities.dp(48);
progressView.setLayoutParams(layoutParams);
ProgressBar progressBar = new ProgressBar(context);
progressView.addView(progressBar);
layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
layoutParams.width = LayoutHelper.WRAP_CONTENT;
layoutParams.height = LayoutHelper.WRAP_CONTENT;
layoutParams.gravity = Gravity.CENTER;
progressView.setLayoutParams(layoutParams);
if (loading && (albumsSorted == null || albumsSorted != null && albumsSorted.isEmpty())) {
progressView.setVisibility(View.VISIBLE);
listView.setEmptyView(null);
} else {
progressView.setVisibility(View.GONE);
listView.setEmptyView(emptyView);
}
return fragmentView;
}
/**
* 初始化视图
*/
private void initView() {
returnBtn = (ImageButton) findViewById(R.id.mouse_return_btn);
returnBtn.setOnClickListener(UIHelper.finish(this));
mouseControl = (TextView) findViewById(R.id.mouse_control);
mouseControl.setOnTouchListener(this);
leftBtn = (Button) findViewById(R.id.mouse_left_btn);
rightBtn = (Button) findViewById(R.id.mouse_right_btn);
leftBtn.setOnClickListener(this);
rightBtn.setOnClickListener(this);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
if (D) Log.d(TAG, "onCreate()");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_terminal);
mTxtTerminal = (TextView) findViewById(R.id.txtTerminal);
mTxtTerminal.setOnTouchListener(mTxtTerminal_OnTouchListener);
mTxtCommand = (EditText) findViewById(R.id.txtCommand);
mTxtCommand.setOnEditorActionListener(mTxtCommand_OnEditorActionListener);
mTxtAlertOverlay = (TextView) findViewById(R.id.txtAlertOverlay);
final Button btnSend = (Button) findViewById(R.id.btnSend);
btnSend.setOnClickListener(mBtnSend_OnClickListener);
}
@Override
protected void onShowProbImpl() {
GridLayout sortArea = findViewById(R.id.sort_area);
sortArea.removeAllViews();
sortArea.setOnDragListener(this);
Set<Integer> nums = new TreeSet<>();
SortingLevel level = ((SortingLevel) getLevel());
String numliststr = getSavedLevelValue("numlist", (String) null);
if (numliststr == null || numliststr.length() == 0) {
int tries = 0;
do {
nums.add(getRand(level.getMaxNum()));
} while (tries++ < 100 && nums.size() < level.getNumItems());
numlist = new ArrayList<>(nums);
do {
Collections.shuffle(numlist);
} while (isSorted(numlist));
} else {
numlist = splitInts(",", numliststr);
deleteSavedLevelValue("numlist");
}
int mlen = (level.getMaxNum() + "").length();
// int xsize = getScreenSize().x;
//
// int tsize = xsize*2/3 / numcolumns / 4 - 5;
// if (tsize>30) tsize = 30;
int tsize = 30 - mlen;
for (int num : numlist) {
String spaces = "";
for (int i = 0; i < Math.max(3, mlen) - (num + "").length(); i++) {
spaces += " ";
}
final String numstr = spaces + num;
TextView item = new TextView(this);
item.setText(numstr);
item.setTag(num);
item.setOnTouchListener(this);
item.setOnDragListener(this);
item.setMaxLines(1);
item.setTextSize(tsize);
item.setTypeface(Typeface.MONOSPACE);
//item.setWidth(xsize*2/3 / numcolumns -10);
//item.setEms(mlen);
item.setGravity(Gravity.END);
GridLayout.LayoutParams lp = new GridLayout.LayoutParams();
lp.setMargins(1, 1, 1, 1);
lp.setGravity(Gravity.CENTER);
item.setLayoutParams(lp);
item.setBackgroundColor(BACKGROUND_COLOR);
item.setPadding(16, 12, 16, 12);
sortArea.addView(item);
}
problemDone = false;
moves = 0;
setFasttimes(level.getNumItems()*300, level.getNumItems()*500, level.getNumItems()*750);
startHint(level.getNumItems());
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manual);
if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler))
Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler());
SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
surfaceView.setOnTouchListener(new SurfaceSwipeTouchListener(this));
m_surfaceHolder = surfaceView.getHolder();
m_surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
// not needed - appears to be the default font
//final Typeface sonyFont = Typeface.createFromFile("system/fonts/Sony_DI_Icons.ttf");
m_tvMsg = (TextView)findViewById(R.id.tvMsg);
m_tvAperture = (TextView)findViewById(R.id.tvAperture);
m_tvAperture.setOnTouchListener(new ApertureSwipeTouchListener(this));
m_tvShutter = (TextView)findViewById(R.id.tvShutter);
m_tvShutter.setOnTouchListener(new ShutterSwipeTouchListener(this));
m_tvISO = (TextView)findViewById(R.id.tvISO);
m_tvISO.setOnTouchListener(new IsoSwipeTouchListener(this));
m_tvExposureCompensation = (TextView)findViewById(R.id.tvExposureCompensation);
m_tvExposureCompensation.setOnTouchListener(new ExposureSwipeTouchListener(this));
m_lExposure = (LinearLayout)findViewById(R.id.lExposure);
m_tvExposure = (TextView)findViewById(R.id.tvExposure);
//noinspection ResourceType
m_tvExposure.setCompoundDrawablesWithIntrinsicBounds(SonyDrawables.p_meteredmanualicon, 0, 0, 0);
m_tvLog = (TextView)findViewById(R.id.tvLog);
m_tvLog.setVisibility(LOGGING_ENABLED ? View.VISIBLE : View.GONE);
m_vHist = (HistogramView)findViewById(R.id.vHist);
m_tvMagnification = (TextView)findViewById(R.id.tvMagnification);
m_lInfoBottom = (TableLayout)findViewById(R.id.lInfoBottom);
m_previewNavView = (PreviewNavView)findViewById(R.id.vPreviewNav);
m_previewNavView.setVisibility(View.GONE);
m_ivDriveMode = (ImageView)findViewById(R.id.ivDriveMode);
m_ivDriveMode.setOnClickListener(this);
m_ivMode = (ImageView)findViewById(R.id.ivMode);
m_ivMode.setOnClickListener(this);
m_ivTimelapse = (ImageView)findViewById(R.id.ivTimelapse);
//noinspection ResourceType
m_ivTimelapse.setImageResource(SonyDrawables.p_16_dd_parts_43_shoot_icon_setting_drivemode_invalid);
m_ivTimelapse.setOnClickListener(this);
m_ivBracket = (ImageView)findViewById(R.id.ivBracket);
//noinspection ResourceType
m_ivBracket.setImageResource(SonyDrawables.p_16_dd_parts_contshot);
m_ivBracket.setOnClickListener(this);
m_vGrid = (GridView)findViewById(R.id.vGrid);
m_tvHint = (TextView)findViewById(R.id.tvHint);
m_tvHint.setVisibility(View.GONE);
m_focusScaleView = (FocusScaleView)findViewById(R.id.vFocusScale);
m_lFocusScale = findViewById(R.id.lFocusScale);
m_lFocusScale.setVisibility(View.GONE);
//noinspection ResourceType
((ImageView)findViewById(R.id.ivFocusRight)).setImageResource(SonyDrawables.p_16_dd_parts_rec_focuscontrol_far);
//noinspection ResourceType
((ImageView)findViewById(R.id.ivFocusLeft)).setImageResource(SonyDrawables.p_16_dd_parts_rec_focuscontrol_near);
setDialMode(DialMode.shutter);
m_prefs = new Preferences(this);
m_haveTouchscreen = getDeviceInfo().getModel().compareTo("ILCE-5100") == 0;
}
@Override
public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& !Settings.canDrawOverlays(getApplicationContext())) {
// Can not draw overlays: pass
stopSelf();
}
try {
active = true;
dbHelper = new KcaDBHelper(getApplicationContext(), null, KCANOTIFY_DB_VERSION);
contextWithLocale = getContextWithLocale(getApplicationContext(), getBaseContext());
//mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mInflater = LayoutInflater.from(contextWithLocale);
mView = mInflater.inflate(R.layout.view_akashi_list, null);
KcaUtils.resizeFullWidthView(getApplicationContext(), mView);
mView.setVisibility(View.GONE);
akashiview = mView.findViewById(R.id.akashiviewlayout);
akashiview.findViewById(R.id.akashiview_head).setOnTouchListener(mViewTouchListener);
akashiview_gtd = (TextView) akashiview.findViewById(R.id.akashiview_gtd);
akashiview_gtd.setOnTouchListener(mViewTouchListener);
akashiview_gtd.setText(getStringWithLocale(R.string.aa_btn_safe_state0));
akashiview_gtd.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.white));
akashiview_star = (TextView) akashiview.findViewById(R.id.akashiview_star);
akashiview_star.setText(getString(R.string.aa_btn_star0));
akashiview_star.setOnTouchListener(mViewTouchListener);
akashiview_list = (ListView) akashiview.findViewById(R.id.akashiview_list);
adapter = new KcaAkashiListViewAdpater2();
mParams = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.WRAP_CONTENT,
getWindowLayoutType(),
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
mParams.gravity = Gravity.CENTER;
mManager = (WindowManager) getSystemService(WINDOW_SERVICE);
Display display = ((WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
Point size = new Point();
display.getSize(size);
displayWidth = size.x;
} catch (Exception e) {
active = false;
error_flag = true;
//sendReport(e, 1);
stopSelf();
}
}
public static void setTextWithLinks(TextView textView, CharSequence html) {
textView.setText(html);
// TODO https://code.google.com/p/android/issues/detail?id=191430
//noinspection Convert2Lambda
textView.setOnTouchListener(new View.OnTouchListener() {
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
if (action == MotionEvent.ACTION_UP ||
action == MotionEvent.ACTION_DOWN) {
int x = (int) event.getX();
int y = (int) event.getY();
TextView widget = (TextView) v;
x -= widget.getTotalPaddingLeft();
y -= widget.getTotalPaddingTop();
x += widget.getScrollX();
y += widget.getScrollY();
Layout layout = widget.getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
ClickableSpan[] links = Spannable.Factory.getInstance()
.newSpannable(widget.getText())
.getSpans(off, off, ClickableSpan.class);
if (links.length != 0) {
if (action == MotionEvent.ACTION_UP) {
if (links[0] instanceof URLSpan) {
openWebUrlExternal(widget.getContext(), null,
((URLSpan) links[0]).getURL(), null);
} else {
links[0].onClick(widget);
}
}
return true;
}
}
return false;
}
});
}