- ログイン
- データベース作成
create database
- データベース確認
- データベースへのユーザ登録
子供たちが絵を描くようにプログラムを書いたりDJしたり作曲したりして遊ぶアプリを作ろうとしています。今はAndroidで鋭意製作中。 (c) Hiroyuki Osaki [since 2000]
@Override
public void onResume() {
super.onResume();
//画面のサイズを取得
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
Display disp = wm.getDefaultDisplay();
int width = disp.getWidth();
//表示したり消したりするためのマネージャーを取得。
FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
//表示したり消したりするフラグメントを取得。
Fragment mFragment1 = fm.findFragmentById(R.id.number_list);
//画面の幅が900pxより小さかったら、消します。それ以外なら表示します。
if (mFragment1 != null) {
if (width < 900) {
ft.hide(mFragment1);
} else
ft.show(mFragment1);
}
ft.commit();
}
FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
if (null == fm.findFragmentByTag(FRAG_TAG)) {
xact.add(R.id.parent, new MyFragment(), FRAG_TAG);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ListView l = (ListView) findViewById(R.id.number_list);
ArrayAdapter numbers = new ArrayAdapter(getApplicationContext(),
android.R.layout.simple_list_item_1,
new String [] {
"one", "two", "three", "four", "five", "six"
});
l.setAdapter(numbers);
l.setOnItemClickListener(this);
}
/**
* Add a Fragment to our stack with n Androids in it
*/
private void stackAFragment(int nAndroids) {
Fragment f = new MyFragment(nAndroids);
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.the_frag, f);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
ft.addToBackStack(null);
ft.commit();
}
/**
* Called when a number gets clicked
*/
public void onItemClick(AdapterView parent, View view, int position, long id) {
stackAFragment(position + 1);
}
private int nAndroids;
public MyFragment() {
}
/**
* Constructor for being created explicitly
*/
public MyFragment(int nAndroids) {
this.nAndroids = nAndroids;
}
/**
* If we are being created with saved state, restore our state
*/
@Override
public void onCreate(Bundle saved) {
super.onCreate(saved);
if (null != saved) {
nAndroids = saved.getInt("nAndroids");
}
}
/**
* Save the number of Androids to be displayed
*/
@Override
public void onSaveInstanceState(Bundle toSave) {
toSave.putInt("nAndroids", nAndroids);
}
/**
* Make a grid and fill it with n Androids
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle saved) {
int n;
Context c = getActivity().getApplicationContext();
LinearLayout l = new LinearLayout(c);
for (n = 0; n < nAndroids; n++) {
ImageView i = new ImageView(c);
i.setImageResource(R.drawable.gallery_thumb);
l.addView(i);
}
return l;
}
class a {
a() {
}
String getname() {
return "this is a.";
}
}
class b extends a {
b() {
super();
}
String getname() {
return super.getname()+"but this is also b";
}
}
Class bclazz = b.class;
a bx = new a();
try {
bx = bclazz.newInstance();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
}
if(bx instanceof b)
Log.w("Test", "this is instanceof b");
if(bx instanceof a)
Log.w("Test", "this is instanceof a");
Log.w("Test", bx.getname());
class a {
a() {
}
String getname() {
return "this is a.";
}
}
class b extends a {
b() {
super();
}
String getname() {
return super.getname()+"but this is also b";
}
}
Class bclazz = b.class;
a bx = new a();
try {
bx = bclazz.newInstance();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
}
Log.w("Test", bx.getname());
package hello
import (
"fmt"
"http"
)
func init() {
http.HandleFunc("/", handler)
}
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello, world!")
}
私は匿名関数を何かと使いたがるので、下記のように書き換えてしまいます。package hello
import (
"fmt"
"http"
)
func init() {
http.HandleFunc("/", func (w http.ResponseWriter, r *http.Request) () {
fmt.Fprint(w, "Hello, world!")
})
}


