(۱۳۹۳/۱۰/۱۷, ۰۲:۴۵ ب.ظ)'alizzz' نوشته: package com.book.chori;
import com.book.chori.R;
import com.book.chori.La;
import com.book.chori.Globals;
import android.widget.ImageView;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.BackgroundColorSpan;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.EditText;
import android.widget.Toast;
import android.view.View.OnClickListener;
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
public class La extends Activity {
public String Subject_number;
public SharedPreferences shared;
public SharedPreferences.Editor editor;
Globals global = new Globals();
public ImageView iv_favorites;
Button next;
EditText et;
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.la);
iv_favorites = (ImageView) findViewById(R.id.imageView1);
Bundle extras = getIntent().getExtras();
if (extras != null) {
Subject_number = extras.getString("subject_13");
}
// Favorites
shared = getSharedPreferences("Prefs", MODE_PRIVATE);
editor = shared.edit();
final String this_subject = "subject_13";
final Boolean b1 = shared.getBoolean(this_subject, false);
if (b1){
iv_favorites.setImageResource(R.drawable.favorite_selected);
}else{
iv_favorites.setImageResource(R.drawable.favorite_not_selected);
}
iv_favorites.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Boolean b2 = shared.getBoolean(this_subject, false);
if (b2){
editor.putBoolean(this_subject, false);
editor.apply();
iv_favorites.setImageResource(R.drawable.favorite_not_selected);
// show message
String message = getResources().getString(R.string.favorites_removed);
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
}else{
editor.putBoolean(this_subject, true);
editor.apply();
iv_favorites.setImageResource(R.drawable.favorite_selected);
// show message
String message = getResources().getString(R.string.favorites_added);
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
}
}
});
Button btn_99=(Button) findViewById(R.id.button3);
btn_99.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent next= new Intent(La.this, Setting.class );
next.putExtra("btn", 99);
startActivity(next);
}
});
et = (EditText) findViewById(R.id.editText1);
tv = (TextView) findViewById(R.id.textView1001);
next = (Button) findViewById(R.id.button1);
next.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
et.clearFocus();
String ett =et.getText().toString();
String tvt =tv.getText().toString();
if(ett.trim().length() < 1){
return;
}
int ofe = tvt.indexOf(ett,0);
Spannable WordtoSpan = new SpannableString(tv.getText());
for(int ofs=0; ofs < tvt.length() && ofe!=-1; ofs=ofe+1)
{
ofe = tvt.indexOf(ett,ofs);
if(ofe == -1)
break;
else
{
WordtoSpan.setSpan(new BackgroundColorSpan(0xFFFFFF00), ofe, ofe+ett.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.setText(WordtoSpan, TextView.BufferType.SPANNABLE);
}
}
}
});
SharedPreferences shp = getSharedPreferences("sett", MODE_PRIVATE);
boolean chbt = shp.getBoolean("chk", true);
int size = shp.getInt("size", 15);
final TextView txt = (TextView) findViewById(R.id.textView1001);
txt.setTextSize(size);
if (chbt)
getWindow()
.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
این یکی از اکتیویتی هاست که توش جستجو و علاقه مندی ها و تنظیم اندازه ی متن و... رو داره.کدهای قسمت جستجو رو براتون پررنگ کردم
ممنون ولی من اصن نفهمیدیم چی به چیه