Java Code Examples for android.widget.TableRow#setOnClickListener()

The following examples show how to use android.widget.TableRow#setOnClickListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StretchViewActivity.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 40; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test stretch scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(StretchViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 2
Source File: PulldownViewActivity.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 30; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test pull down scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(PulldownViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 3
Source File: StretchViewActivity.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 40; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test stretch scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(StretchViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 4
Source File: PulldownViewActivity.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 30; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test pull down scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(PulldownViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 5
Source File: StretchViewActivity.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 40; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test stretch scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(StretchViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 6
Source File: PulldownViewActivity.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 30; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test pull down scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(PulldownViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 7
Source File: StretchViewActivity.java    From PullScrollView with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 40; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test stretch scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(StretchViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 8
Source File: PulldownViewActivity.java    From PullScrollView with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 30; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test pull down scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(PulldownViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example 9
Source File: RadioSectionFragment.java    From satstat with GNU General Public License v3.0 4 votes vote down vote up
private final void addWifiResult(ScanResult result) {
	// needed to pass a persistent reference to the OnClickListener
	final ScanResult r = result;
	android.view.View.OnClickListener clis = new android.view.View.OnClickListener () {

		@Override
		public void onClick(View v) {
			onWifiEntryClick(r.BSSID);
		}
	};

	LinearLayout wifiLayout = new LinearLayout(wifiAps.getContext());
	wifiLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	wifiLayout.setOrientation(LinearLayout.HORIZONTAL);
	wifiLayout.setWeightSum(22);
	wifiLayout.setMeasureWithLargestChildEnabled(false);

	ImageView wifiType = new ImageView(wifiAps.getContext());
	wifiType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.MATCH_PARENT, 3));
	if (WifiCapabilities.isAdhoc(result)) {
		wifiType.setImageResource(R.drawable.ic_content_wifi_adhoc);
	} else if ((WifiCapabilities.isEnterprise(result)) || (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.EAP)) {
		wifiType.setImageResource(R.drawable.ic_content_wifi_eap);
	} else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.PSK) {
		wifiType.setImageResource(R.drawable.ic_content_wifi_psk);
	} else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.WEP) {
		wifiType.setImageResource(R.drawable.ic_content_wifi_wep);
	} else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.OPEN) {
		wifiType.setImageResource(R.drawable.ic_content_wifi_open);
	} else {
		wifiType.setImageResource(R.drawable.ic_content_wifi_unknown);
	}

	wifiType.setScaleType(ScaleType.CENTER);
	wifiLayout.addView(wifiType);

	TableLayout wifiDetails = new TableLayout(wifiAps.getContext());
	wifiDetails.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
	TableRow innerRow1 = new TableRow(wifiAps.getContext());
	TextView newMac = new TextView(wifiAps.getContext());
	newMac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 14));
	newMac.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
	newMac.setText(result.BSSID);
	innerRow1.addView(newMac);
	TextView newCh = new TextView(wifiAps.getContext());
	newCh.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
	newCh.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
	newCh.setText(getChannelFromFrequency(result.frequency));
	innerRow1.addView(newCh);
	TextView newLevel = new TextView(wifiAps.getContext());
	newLevel.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
	newLevel.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
	newLevel.setText(String.valueOf(result.level));
	innerRow1.addView(newLevel);
	innerRow1.setOnClickListener(clis);
	wifiDetails.addView(innerRow1,new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

	TableRow innerRow2 = new TableRow(wifiAps.getContext());
	TextView newSSID = new TextView(wifiAps.getContext());
	newSSID.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
	newSSID.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Small);
	newSSID.setText(result.SSID);
	innerRow2.addView(newSSID);
	innerRow2.setOnClickListener(clis);
	wifiDetails.addView(innerRow2, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

	wifiLayout.addView(wifiDetails);
	wifiLayout.setOnClickListener(clis);
	wifiAps.addView(wifiLayout);
}