캐릭캐릭 체인지!

제가 만든게 아닙니다. ㅎ

아슈타르테!!!


MainActivity.java

package com.stillthere.mysubject01.Activity; 
 
import android.os.Bundle; 
import android.support.v7.app.AppCompatActivity; 
import android.widget.TextView; 
 
import com.stillthere.mysubject01.AsyncTask.GetTextTask; 
import com.stillthere.mysubject01.Handler.BackPressCloseHandler; 
import com.stillthere.mysubject01.R; 
 
public class MainActivity extends AppCompatActivity { 
    private String str; 
    private TextView textView; 
 
    private BackPressCloseHandler backPressCloseHandler; 
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.activity_main); 
 
        backPressCloseHandler = new BackPressCloseHandler(this); 
 
 
        textView = (TextView) findViewById(R.id.textView); 
 
        try { 
            str = new GetTextTask() 
                    .execute("http://stillthere.cafe24.com/score.jsp").get(); 
 
            textView.setText(str); 
        } catch (Exception e) { 
            e.printStackTrace(); 
        } 
    } 
 
    @Override 
    public void onBackPressed() { 
        backPressCloseHandler.onBackPressed(); 
    } 
} 

다운로드

견고한 다리

다운로드
 

MainActivity.java

package kr.razberry.test; 
 
import android.content.Context; 
import android.database.Cursor; 
import android.database.sqlite.SQLiteDatabase; 
import android.database.sqlite.SQLiteException; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.widget.AdapterView; 
import android.widget.EditText; 
import android.widget.LinearLayout; 
import android.widget.ListView; 
import android.widget.Toast; 
import java.util.Vector; 
 
 
public class MainActivity extends AppCompatActivity { 
    //Vector cardVec = new Vector(); 
    DBHelper helper; 
    SQLiteDatabase db; 
    EditText nameTxt; 
    EditText telTxt; 
    ListView cardlistView = null; 
    Friend clickedFriend = null; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.activity_main); 
        helper = new DBHelper(this); 
        try { 
            db = helper.getWritableDatabase(); 
        } 
        catch (SQLiteException ex) { 
            db = helper.getReadableDatabase(); 
        } 
        nameTxt = (EditText) findViewById(R.id.nameTxt); 
        telTxt = (EditText) findViewById(R.id.telTxt); 
        cardlistView = (ListView)findViewById(R.id.listview); 
 
        cardlistView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
            @Override 
            public void onItemClick(AdapterView <?> parent, View v, int position, long id) { 
                nameTxt.setText(((EditText)(v.findViewById(R.id.nameTxt))).getText().toString()); 
                telTxt.setText(((EditText)(v.findViewById(R.id.telTxt))).getText().toString()); 
                clickedFriend = (Friend)v.getTag(); 
                Toast.makeText(getBaseContext(),clickedFriend.getName(),Toast.LENGTH_LONG).show(); 
            } 
        }); 
    } 
 
    public void makeToast(View V) { 
        Toast.makeText(getBaseContext(),"btnClicked" ,Toast.LENGTH_SHORT).show(); 
    } 
    public void insertCard(View v) { 
        String name = nameTxt.getText().toString(); 
        String tel = telTxt.getText().toString(); 
        db.execSQL("INSERT INTO contacts VALUES (null, '" + name + "', '" + tel + "');"); 
        Toast.makeText(getApplicationContext(),"성공적으로 추가되었음",Toast.LENGTH_SHORT).show(); 
        nameTxt.setText(""); 
        telTxt.setText(""); 
        showList("SELECT * FROM contacts"); 
    } 
    public void updateCard(View v) { 
        if(clickedFriend == null) { 
            return; 
        } 
 
        String name = nameTxt.getText().toString(); 
        String tel = telTxt.getText().toString(); 
       db.execSQL("update contacts set name='" + name + "', tel='" + tel + "' where name='" + clickedFriend.getName() + "';"); 
        showList("SELECT * FROM contacts"); 
    } 
 
    public void deleteCard(View v) { 
        if(clickedFriend == null) { 
            return; 
        } 
        db.execSQL("delete from contacts where name = '" + clickedFriend.getName() + "'; "); 
        showList("SELECT * FROM contacts"); 
    } 
 
    public void searchCard(View v) { 
        String name = nameTxt.getText().toString(); 
        String tel = telTxt.getText().toString(); 
 
        showList("SELECT * FROM contacts where name like '%" + name + "%' and tel like '%" + tel +"%'"); 
    } 
    private void showList(String s) { 
        Cursor cursor = db.rawQuery(s, null); 
        startManagingCursor(cursor); 
        String[] from = { "name" , "tel" }; 
        int[] to = { R.id.nameTxt, R.id.telTxt }; 
        MyDBCursorAdapter adapter = new MyDBCursorAdapter(this, R.layout.cardlayout, cursor, from, to); 
 
        cardlistView.setAdapter(adapter); 
 
        clickedFriend = null; 
        nameTxt.setText(""); 
        telTxt.setText(""); 
    } 
 
 
}

 

흔들리는 격전지

MainActivity.java

package kr.razberry.test; 
 
import android.content.Context; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.widget.AdapterView; 
import android.widget.EditText; 
import android.widget.LinearLayout; 
import android.widget.ListView; 
import android.widget.Toast; 
import java.util.Vector; 
 
 
public class MainActivity extends AppCompatActivity { 
    Vector cardVec = new Vector(); 
    LinearLayout listlayout = null; 
    EditText nameTxt; 
    EditText telTxt; 
    ListView cardlistView = null; 
    MyAdapter adapter; 
    Friend clickedFriend = null; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.activity_main); 
        listlayout = (LinearLayout)findViewById(R.id.listlayout); 
        nameTxt = (EditText) findViewById(R.id.nameTxt); 
        telTxt = (EditText) findViewById(R.id.telTxt); 
        cardlistView = (ListView)findViewById(R.id.listview); 
        adapter = new MyAdapter(MainActivity.this, cardVec); 
 
        cardlistView.setAdapter(adapter); 
        cardlistView.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
            @Override 
            public void onItemClick(AdapterView <?> parent, View v, int position, long id) { 
                Toast.makeText(getBaseContext(),""+position,Toast.LENGTH_LONG).show(); 
                nameTxt.setText(((EditText)(v.findViewById(R.id.nameTxt))).getText().toString()); 
                telTxt.setText(((EditText)(v.findViewById(R.id.telTxt))).getText().toString()); 
                clickedFriend = (Friend)v.getTag(); 
            } 
        }); 
    } 
 
    public void makeToast(View V) { 
        Toast.makeText(getBaseContext(),"btnClicked" ,Toast.LENGTH_SHORT).show(); 
    } 
    public void insertCard(View v) { 
        String name = nameTxt.getText().toString(); 
        String tel = telTxt.getText().toString(); 
        Friend friend = new Friend(name,tel); 
        cardVec.add(friend); 
 
        LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
        LinearLayout cardLayout = (LinearLayout)inflater.inflate(R.layout.cardlayout, null, false); 
        ((EditText)cardLayout.findViewById(R.id.nameTxt)).setText(name); 
        ((EditText)cardLayout.findViewById(R.id.telTxt)).setText(tel); 
        listlayout.removeAllViews(); 
        listlayout.addView(cardLayout); 
        adapter.setData(cardVec); 
        adapter.notifyDataSetChanged(); 
    } 
    public void updateCard(View v) { 
        String name = nameTxt.getText().toString(); 
        String tel = telTxt.getText().toString(); 
        clickedFriend.setName(name); 
        clickedFriend.setTel(tel); 
        adapter.setData(cardVec); 
        adapter.notifyDataSetChanged(); 
    } 
 
    public void deleteCard(View v) { 
        cardVec.remove(clickedFriend); 
        adapter.setData(cardVec); 
        adapter.notifyDataSetChanged(); 
    } 
    public void searchCard(View v) { 
        Vector searchVec = new Vector(); 
 
        for(Object obj : cardVec) { 
            if(((Friend)obj).contains(nameTxt.getText().toString(), telTxt.getText().toString())){ 
                searchVec.add(obj); 
                Toast.makeText(getApplicationContext(),((Friend)obj).getName(), Toast.LENGTH_LONG).show(); 
            } 
        } 
 
        adapter.setData(searchVec); 
        adapter.notifyDataSetChanged(); 
    } 
}

Friend.java

package kr.razberry.test; 
 
/** 
 * Created by taki on 2016-10-23. 
 */ 
 
public class Friend { 
    private String name = ""; 
    private String tel = ""; 
 
    public Friend(String name, String tel) { 
        this.name = name; 
        this.tel = tel; 
    } 
 
    public String getTel() { 
        return tel; 
    } 
 
    public void setTel(String tel) { 
        this.tel = tel; 
    } 
 
    public String getName() { 
        return name; 
    } 
 
    public void setName(String name) { 
        this.name = name; 
    } 
 
    public boolean contains(String name, String tel) { 
        if (!(name != null && name.length() > 0 && !this.name.contains(name))) 
            if (!(tel != null && tel.length() > 0 && !this.tel.contains(tel))) return true; 
        return false; 
    } 
 
    @Override 
    public String toString() { 
        return super.toString(); 
    } 
} 

MyAdapter.java

package kr.razberry.test; 
 
import android.app.Activity; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.ArrayAdapter; 
import android.widget.EditText; 
import java.util.Vector; 
 
public class MyAdapter extends ArrayAdapter<Friend> { 
  private final Activity context; 
  private Vector vec; 
  public MyAdapter(Activity context, Vector vec) { 
    super(context, R.layout.cardlayout, vec); 
 
    this.context = context; 
    this.vec = vec; 
  } 
 
  public void setData(Vector vec) { 
    this.vec = vec; 
  } 
 
  @Override 
  public int getCount() { 
    return vec.size(); 
  } 
 
  @Override 
  public View getView(int position, View convertView, ViewGroup parent) { 
    LayoutInflater inflater = context.getLayoutInflater(); 
    View cardView = inflater.inflate(R.layout.cardlayout, null, false); 
    Friend friend = (Friend)vec.get(position); 
    ((EditText)cardView.findViewById(R.id.nameTxt)).setText(friend.getName()); 
    ((EditText)cardView.findViewById(R.id.telTxt)).setText(friend.getTel()); 
    cardView.setTag(friend); 
    return cardView; 
  } 
}

다운로드