Example usage for android.widget TextView setOnCreateContextMenuListener

List of usage examples for android.widget TextView setOnCreateContextMenuListener

Introduction

In this page you can find the example usage for android.widget TextView setOnCreateContextMenuListener.

Prototype

public void setOnCreateContextMenuListener(OnCreateContextMenuListener l) 

Source Link

Document

Register a callback to be invoked when the context menu for this view is being built.

Usage

From source file:com.abid_mujtaba.fetchheaders.AccountsActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.accounts);//from w w  w. jav a2 s.c  o  m

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    LinearLayout accountList = (LinearLayout) findViewById(R.id.account_list);

    LayoutInflater li = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    for (int ii = 0; ii < Account.numberOfAccounts(); ii++) {
        TextView tv = (TextView) li.inflate(R.layout.account_setting_name, null);
        tv.setText(Account.get(ii).name());
        tv.setId(ii); // Store the account_id as the view id
        tv.setOnCreateContextMenuListener(onCreateContextMenuListener);
        tv.setOnTouchListener(onTouchListener);

        tv.setOnClickListener(listener);

        accountList.addView(tv);
    }
}