A sentimental robot

Menu 본문

Android Studio

Menu

GOD03219 2018. 2. 7. 17:01
package com.example.i310_54.myapplication08;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ContextMenu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;

import java.util.Random;


public class MainActivity extends AppCompatActivity {
String TAG = "eun";

@Override
public boolean onContextItemSelected(MenuItem item) {

Log.d(TAG, "onContextItemSelected: "+item.getItemId());
return true;
}

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);

menu.setHeaderTitle("Zoo");
menu.add(0, 1, 0, "tiger");
menu.add(0, 2, 0, "elephant");
menu.add(0, 3, 0, "rabbit");


}

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

LinearLayout li = findViewById(R.id.li);
registerForContextMenu(li); // layout을 꾹 누르면 메뉴 생성


}

}

'Android Studio' 카테고리의 다른 글

AsyncTask  (0) 2018.12.14
Thread를 이용한 UI  (0) 2018.02.07
My xml  (0) 2018.02.06
Customizing  (0) 2018.02.06
OnTouch  (0) 2018.02.06